Hello,
I am amateur with VB database usage.
I've written a little database that keeps track of names, address, phone numbers etc. It displays the data in a DataGrid and stores them in a database. I am able to store and UPDATE new records without problems. Because of my ignorance of VB databases usage, I've tried for hours to get it to DELETE a record. I'm to the point I need to ask for expert help. Here is my code, which is based off of some code I found on the Internet:
I would greatly appreciate any help.
Thanks,
John
[CODE=vb]Public Sub Delete_TableRow (ByVal RowNumber As Integer, ByVal KeyID As Integer)
myOleDbConnecti on = New _
OleDbConnection ("provider=micr osoft.jet.oledb .4.0;" & _
"user id=admin; Data Source=" & myDataSource)
Dim OleDbUpdateComm and As System.Data.Ole Db.OleDbCommand
OleDbUpdateComm and = New System.Data.Ole Db.OleDbCommand
OleDbUpdateComm and.CommandText = _
"Delete from Table1 WHERE id=" & KeyID & " ; "
OleDbUpdateComm and.Connection = myOleDbConnecti on
myOleDbDataAdap ter.UpdateComma nd = OleDbUpdateComm and
myOleDbDataAdap ter.UpdateComma nd.ExecuteNonQu ery()
End Sub[/CODE]
I am amateur with VB database usage.
I've written a little database that keeps track of names, address, phone numbers etc. It displays the data in a DataGrid and stores them in a database. I am able to store and UPDATE new records without problems. Because of my ignorance of VB databases usage, I've tried for hours to get it to DELETE a record. I'm to the point I need to ask for expert help. Here is my code, which is based off of some code I found on the Internet:
I would greatly appreciate any help.
Thanks,
John
[CODE=vb]Public Sub Delete_TableRow (ByVal RowNumber As Integer, ByVal KeyID As Integer)
myOleDbConnecti on = New _
OleDbConnection ("provider=micr osoft.jet.oledb .4.0;" & _
"user id=admin; Data Source=" & myDataSource)
Dim OleDbUpdateComm and As System.Data.Ole Db.OleDbCommand
OleDbUpdateComm and = New System.Data.Ole Db.OleDbCommand
OleDbUpdateComm and.CommandText = _
"Delete from Table1 WHERE id=" & KeyID & " ; "
OleDbUpdateComm and.Connection = myOleDbConnecti on
myOleDbDataAdap ter.UpdateComma nd = OleDbUpdateComm and
myOleDbDataAdap ter.UpdateComma nd.ExecuteNonQu ery()
End Sub[/CODE]
Comment