T
Terry Burns
This code is the contaxt menu handler assoc with a data grid, bound to
tableEvents and using daEvents adapter, the row deletes without error
message but does not delete at the access db, any ideas ??
Private Sub popUp_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim cc, sp As Point
Dim cmi As MenuItem
Dim TR As DataRow
Dim DT As DataTable
Dim DeleteCmd As New OleDbCommand
'open connection
con.Open()
cmi = DirectCast(sender, MenuItem)
Select Case cmi.Text
Case "Delete"
'Setup the Delete Command
DeleteCmd.CommandText = "DELETE FROM [Events] WHERE ([ID] = ?) AND ([Action]
= ?) AND ([EventType] = ?) AND ([Perso" & _
"nIndex] = ? OR ? IS NULL AND [PersonIndex] IS NULL)"
DeleteCmd.Connection = con
DeleteCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_ID",
System.Data.OleDb.OleDbType.Integer, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"ID", System.Data.DataRowVersion.Original, Nothing))
DeleteCmd.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Action",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"Action", System.Data.DataRowVersion.Original, Nothing))
DeleteCmd.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_EventType",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"EventType", System.Data.DataRowVersion.Original, Nothing))
DeleteCmd.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_PersonIndex",
System.Data.OleDb.OleDbType.Integer, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"PersonIndex", System.Data.DataRowVersion.Original, Nothing))
DeleteCmd.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_PersonIndex1",
System.Data.OleDb.OleDbType.Integer, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"PersonIndex", System.Data.DataRowVersion.Original, Nothing))
tableEvents.Rows.RemoveAt(dgEvents.CurrentRowIndex)
daEvents.DeleteCommand = DeleteCmd
daEvents.Update(tableEvents)
Case "Add"
End Select
con.Close()
tableEvents and using daEvents adapter, the row deletes without error
message but does not delete at the access db, any ideas ??
Private Sub popUp_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim cc, sp As Point
Dim cmi As MenuItem
Dim TR As DataRow
Dim DT As DataTable
Dim DeleteCmd As New OleDbCommand
'open connection
con.Open()
cmi = DirectCast(sender, MenuItem)
Select Case cmi.Text
Case "Delete"
'Setup the Delete Command
DeleteCmd.CommandText = "DELETE FROM [Events] WHERE ([ID] = ?) AND ([Action]
= ?) AND ([EventType] = ?) AND ([Perso" & _
"nIndex] = ? OR ? IS NULL AND [PersonIndex] IS NULL)"
DeleteCmd.Connection = con
DeleteCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_ID",
System.Data.OleDb.OleDbType.Integer, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"ID", System.Data.DataRowVersion.Original, Nothing))
DeleteCmd.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Action",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"Action", System.Data.DataRowVersion.Original, Nothing))
DeleteCmd.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_EventType",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"EventType", System.Data.DataRowVersion.Original, Nothing))
DeleteCmd.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_PersonIndex",
System.Data.OleDb.OleDbType.Integer, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"PersonIndex", System.Data.DataRowVersion.Original, Nothing))
DeleteCmd.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_PersonIndex1",
System.Data.OleDb.OleDbType.Integer, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"PersonIndex", System.Data.DataRowVersion.Original, Nothing))
tableEvents.Rows.RemoveAt(dgEvents.CurrentRowIndex)
daEvents.DeleteCommand = DeleteCmd
daEvents.Update(tableEvents)
Case "Add"
End Select
con.Close()