473,666 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.QuerySt ring("id")
Dim strSQL As String = "INSERT INTO tblRackInfo (ServerId,Appli cation)
VALUES ( @ServerID,@Appl ication)"
Dim MyConn as New SQLConnection(s trConn)
Dim Cmd as New SQLCommand(strS QL, MyConn)
cmd.Parameters. Add(New SQLParameter("@ Serverid", intServerId))
cmd.Parameters. Add(New SQLParameter("@ Application", txtApp.text))
MyConn.Open()
cmd.ExecuteNonQ uery
MyConn.Close()
Case "Delete"

'Dim chk as CheckBox = CType(itm.FindC ontrol("chkRemo ve"), CheckBox)
' Dim lblID as Label =
rptDelApps.Item s(e.Item.ItemIn dex).cells(1).F indControl("lbl ID")
For Each MyItem As RepeaterItem In rptDelApps.Item s
If MyItem.ItemType = ListItemType.It em Or MyItem.ItemType =
ListItemType.Al ternatingItem Then
For Each MyControl As Control In MyItem.Controls
If TypeOf (MyControl) Is System.Web.UI.W ebControls.Chec kBox Then
If CType(MyControl , CheckBox).Check ed = True Then
' Dim lblID as Label = MyItem.FindCont rol("lblID")
Dim DeleteCmd As String = "DELETE from tblRackInfo Where id ='" &
Request.QuerySt ring("id") & "'"
Dim MyConn as New SQLConnection(s trConn)
Dim Cmd as New SQLCommand(Dele teCmd, MyConn)
'Cmd.Parameters .Add(New SqlParameter("@ ID", lblID.Text))
MyConn.Open()
Cmd.ExecuteNonQ uery()
MyConn.Close()
End If
End If
Next
End If
Next
rptDelApps.Data Bind()

Case "Edit"
Dim MyConn as New SQLConnection(s trConn)
Dim Cmd as New SQLCommand(strS QL, MyConn)
Dim intServerId = Request.QuerySt ring("id")
strSQl ="UPDATE tblTPServers SET Name =@Name, Type =@Type, OS =@OS, CPU
=@CPU, RAM =@RAM, IP=@IP WHERE id='" & intServerId & "'"
MyConn = New SqlConnection(s trConn)
Cmd = New SqlCommand(strS ql, MyConn)

Cmd.Parameters. Add(New SQLParameter("@ Name",txtServer .Text))
Cmd.Parameters. Add(New SQLParameter("@ Type", txtServerType.t ext))
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.ExecuteNonQ uery
MyConn.Close()

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

Have you tried setting a breakpoint at "Cmd.ExecuteNon Query()" 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
1980
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 back to the SQL Server table back. The functionality I am looking is almost the same as In the SQL Enterprise Manager whereby I can choose a table open the table and then return all rows and I can maintain the same and save it back to
10
2036
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 called updatefred.php and equally the page which processes a delete would be deletefred.php. I like splitting the pages up this way, it feels less cluttered and more organised than throwing all the functionality in one fred.php.
11
2685
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 has a datagrid that loads up just fine, but when I click on any link that updates the page, i.e. a column header to sort the database, it returns a 404 error. Any ideas why it works the for the inital load and not on a postback?
4
3709
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 file via some editable controls such as text boxes , option boxes etc. how can i implment this , should i use another xslt file with <INPUT> controls . if so how can i save the result back using the asp.net
6
1520
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 the list. This has some text boxes for the data, and a button to click when they are ready to submit. To the user, this looks like two separate forms, one containing a grid of existing data and one where they add new data.
5
2774
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 to the database to get the next page. Is there a way to use the dataset to allow us to read back and forth in it instead of going back to the database to get it? Thanks,
3
2339
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
8083
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 user clicks the save button on editpage.aspx, the page updates the database and then redirects to the default.aspx page.
2
6940
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 and i am implementing it in my website....
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8869
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.