I have a datagrid where I have successfully been able to get the current row number to match the selected row. I can also delete a row by an ID number.
What I need to do is match the ID number to the ID number in the currow so I can delete it with my Delete From Statement.
Here is my code so far. What do I need to do?
VB Code:
Dim curRow As Integer curRow = DataGrid1.CurrentRowIndex MsgBox(curRow) Dim strDataBaseName As String = "C:\path\dbname.mdb" Dim cnn As New OleDb.OleDbConnection( _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & strDataBaseName) Dim cmd As New OleDb.OleDbCommand cnn.Open() cmd.Connection = cnn Try cmd.CommandText = "Delete From TimeGr Where ID = " & 33 ' map this ' to the ID in the current row instead of having it hardwired in ' the code. cmd.ExecuteNonQuery() Catch exError As Exception MessageBox.Show(exError.Message) End Try




Reply With Quote