By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,913 Members | 1,464 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,913 IT Pros & Developers. It's quick & easy.

problem in deleting data

P: 11
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
MSFlexGrid1.RemoveItem (MSFlexGrid1.Row)
MsgBox "You Deleted a record!", vbOKCancel + vbInformation, "Delete"
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)
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 =)
Nov 5 '09 #1
Share this Question
Share on Google+
1 Reply

P: 1
rs.Open "Delete from Sample2 Where ID ='" & someid & "'", cn, adOpenDynamic, adLockPessimistic

Use this query to delete your data.
Jan 2 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.