Hi everyone,
I have a problem in deleting a data that is connected on the database.. I tried this code but it shows me an error: Run-time error '-2147217900(80040e14)': Syntax error in string in query expression 'ID=". Here is the code that i did:
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim ab As String
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\My Documents\sample adding, deleting data\sample123.mdb;Persist Security Info=False"
rs.Open "Delete from Sample2 Where ID ='", cn, adOpenDynamic, adLockPessimistic
ab = MsgBox("Are you sure you want to delete a record?", vbInformation + vbYesNo, "Delete record")
If ab = Yes Then
If Not rs.EOF Then
rs.Delete
rs.Update
MSFlexGrid1.RemoveItem (MSFlexGrid1.Row)
MsgBox "You Deleted a record!", vbOKCancel + vbInformation, "Delete"
Else
MSFlexGrid1.Rows = MSFlexGrid1.FixedRows
End If
End If
Also I tried other solution but only the flexgrid deletes the data and not on a database.. Here's the code:
If MSFlexGrid1.Rows > MSFlexGrid1.FixedRows + 1 Then
MSFlexGrid1.RemoveItem (MSFlexGrid1.Row)
Else
MSFlexGrid1.Rows = MSFlexGrid1.FixedRows
End If
I'm using Microsoft Access 2003 as my database/backend..
Can someone help me in my problem? In adding a record, I don't have any problem because it works already.. but in deleting a data, i can't.. I will very appreciate to those who replied on my message..
Very Thanks,
Kyosuke =)