473,386 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

one page to edit, delete, and add data to a database

I am creating one page to edit, delete, and add data to a database. The Add
code works but the Edit and Delete do not. What am I doing wrong? If you need
more code let me know.
Thanks
Code:
Sub Submit(Source as Object, E as EventArgs)

Select Case strCommand
Case "Add"
'Create the appropriate SQL statement
Dim intServerId = Request.QueryString("id")
Dim strSQL As String = "INSERT INTO tblRackInfo (ServerId,Application)
VALUES ( @ServerID,@Application)"
Dim MyConn as New SQLConnection(strConn)
Dim Cmd as New SQLCommand(strSQL, MyConn)
cmd.Parameters.Add(New SQLParameter("@Serverid", intServerId))
cmd.Parameters.Add(New SQLParameter("@Application", txtApp.text))
MyConn.Open()
cmd.ExecuteNonQuery
MyConn.Close()
Case "Delete"

'Dim chk as CheckBox = CType(itm.FindControl("chkRemove"), CheckBox)
' Dim lblID as Label =
rptDelApps.Items(e.Item.ItemIndex).cells(1).FindCo ntrol("lblID")
For Each MyItem As RepeaterItem In rptDelApps.Items
If MyItem.ItemType = ListItemType.Item Or MyItem.ItemType =
ListItemType.AlternatingItem Then
For Each MyControl As Control In MyItem.Controls
If TypeOf (MyControl) Is System.Web.UI.WebControls.CheckBox Then
If CType(MyControl, CheckBox).Checked = True Then
' Dim lblID as Label = MyItem.FindControl("lblID")
Dim DeleteCmd As String = "DELETE from tblRackInfo Where id ='" &
Request.QueryString("id") & "'"
Dim MyConn as New SQLConnection(strConn)
Dim Cmd as New SQLCommand(DeleteCmd, MyConn)
'Cmd.Parameters.Add(New SqlParameter("@ID", lblID.Text))
MyConn.Open()
Cmd.ExecuteNonQuery()
MyConn.Close()
End If
End If
Next
End If
Next
rptDelApps.DataBind()

Case "Edit"
Dim MyConn as New SQLConnection(strConn)
Dim Cmd as New SQLCommand(strSQL, MyConn)
Dim intServerId = Request.QueryString("id")
strSQl ="UPDATE tblTPServers SET Name =@Name, Type =@Type, OS =@OS, CPU
=@CPU, RAM =@RAM, IP=@IP WHERE id='" & intServerId & "'"
MyConn = New SqlConnection(strConn)
Cmd = New SqlCommand(strSql, MyConn)

Cmd.Parameters.Add(New SQLParameter("@Name",txtServer.Text))
Cmd.Parameters.Add(New SQLParameter("@Type", txtServerType.text))
Cmd.Parameters.Add(New SQLParameter("@OS", txtOS.text))
Cmd.Parameters.Add(New SQLParameter("@CPU", txtCPU.text))
Cmd.Parameters.Add(New SQLParameter("@RAM", txtRAM.text))
Cmd.Parameters.Add(New SQLParameter("@IP", txtIP.text))
MyConn.Open()
cmd.ExecuteNonQuery
MyConn.Close()

End Select
End Sub
Nov 18 '05 #1
1 1906
Hi,

Have you tried setting a breakpoint at "Cmd.ExecuteNonQuery()" line to
see if when you choose to delete, it gets to that line?

If you are getting to that line and it executes without any errors,
double check that the "DeleteCmd" string is correct.
Hope this helps.

Tod Birdsall
http://tod1d.blogspot.com

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Belinda | last post by:
Hello All I need to read a SQL Server table into a Web Page and within the Web Page to permit my users to make changes to the records, delete or add new records and then save the entire contents...
10
by: Jim | last post by:
Hi, Let me explain how I'd generally do things. For a page where the user edits data, I'd generally call it something like editfred.php (for example), the page which updates the data would be...
11
by: Steve Hoyer | last post by:
I am trying to deploy my first asp.net app to our webserver (2K server, IIS 5) My start page comes up and you can get to the subsequent pages that are tied into our sql server (2K). Each page...
4
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml...
6
by: Alan Silver | last post by:
Hello, I have a page that displays a data list with info from a database. The grid has the usual stuff, edit, update, delete etc. Below this I have a section where they can add a new entry to...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
3
by: Saint | last post by:
My Server Enivronment: MS Windows Server 2003 Standard Edition, Service Pack 1 (running as a VM on a Intel Xeon server) IIS running on Port 80 Apache 2.0.63 running on port 8080 PHP 5.2.5
7
by: seanmatthewwalsh | last post by:
Hi I have a page (default.aspx) that pulls it's HTML from a database. I then have a "content management" page (editpage.aspx) that allows the user to edit the HTML in the database. When the...
2
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.