SQL Delete Statement

13063154

Member
Joined
Aug 24, 2005
Messages
9
Location
Vanderbijlpark, Gauteng, SA
Programming Experience
Beginner
Hi

I am trying to set a delete statement to remove a student from a SQL server database. My statement is as follows:

(It reads the data into a datagrid and then the user can select the line in the datagrid and then choose delete button)


Case "Delete"
Try
Dim row As DataRow
row = GetCurrentRow()
If Not IsNothing(row) Then
row.Delete()
Me.Changed = True
End If
Catch ex As Exception
oEx.Handle(ex, Dev.[Shared].Common.ExceptionDev.SeverityTypes.Critical,
Me.GetType.ToString, "tbBase_ButtonClick")
End Try
Is this correct? What am i doing wrong it deletes the student from the data grid but when i go back into the app. or click refresh it brings the student that was deleted back.
 
Assuming what are you doing and how you need to know this. All the changes you want to make against DB you should do through the dataAdapter which is kind of negotiator between the dataset and DB. So, what you do with the code above is removing the row from datagrid only.
Perform a delete query of the DataAdapter object.

Regards ;)
 
Hi Kulrom

Sorry to be such a pain, but i am new to data connection with sql server. So i am not exactly sure how to send a query to the database. What is the format to do this, after using the above statement to delete the selected student according to the student number in the row of that datagrid?
 
Back
Top