473,587 Members | 2,547 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem in deleting data

11 New Member
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(8004 0e14)': Syntax error in string in query expression 'ID=". Here is the code that i did:

Dim cn As New ADODB.Connectio n
Dim rs As New ADODB.Recordset
Dim ab As String

cn.Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=C:\Docum ents and Settings\Admini strator\My Documents\sampl e adding, deleting data\sample123. mdb;Persist Security Info=False"
rs.Open "Delete from Sample2 Where ID ='", cn, adOpenDynamic, adLockPessimist ic

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.Rem oveItem (MSFlexGrid1.Ro w)
MsgBox "You Deleted a record!", vbOKCancel + vbInformation, "Delete"
Else
MSFlexGrid1.Row s = MSFlexGrid1.Fix edRows
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.Row s > MSFlexGrid1.Fix edRows + 1 Then
MSFlexGrid1.Rem oveItem (MSFlexGrid1.Ro w)
Else
MSFlexGrid1.Row s = MSFlexGrid1.Fix edRows
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
1 1718
mindgames
1 New Member
rs.Open "Delete from Sample2 Where ID ='" & someid & "'", cn, adOpenDynamic, adLockPessimist ic

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

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

Similar topics

6
5759
by: Hennie de Nooijer | last post by:
Hi, Currently we're a building a metadatadriven datawarehouse in SQL Server 2000. We're investigating the possibility of the updating tables with enormeous number of updates and insert and the use of checkpoints (for simple recovery and Backup Log for full recovery). On several website people speak about full transaction log and the pace...
6
1835
by: RBohannon | last post by:
I'm using Access 2000. I have a DB with 19 tables, and I have just split it. When I look in the back end, all 19 tables are there. However, only 17 of them in the front end are actually linked to the back end. When I look at the table objects in the front end, two of them do not have arrows to indicate they are linked. These same two...
13
9496
by: Bob Darlington | last post by:
I have a repair and backup database routine which runs when a user closes down my application. It works fine in my development machine, but breaks on a client's at the following line: If Dir(strLDB) <> "" Then Kill (strLDB) where strLDB is the path to the ldb file. The client advises that the ldb doesn't lurk after the program closes. Any...
2
1707
by: SiouxieQ | last post by:
Hi there, I'm using the code below to try to delete a name from a list of names in a file. Unfortunately it doesn't quite do what I want it to. Instead of looking for the name in the textbox and deleting that it is just deleting the first line of data in the file.
4
2895
by: perspolis | last post by:
Hi all I have a master-detail tables in sql server. I use SqlTransaction to insert data into both tables. it works well but if I check the "Cascade Delete Related Records" option in it's realtion in sql server my SqlTransaction dosen't work and get timeout error.. please help me thanks in advance
1
3100
by: Pat | last post by:
Hi all, I have a really awkward situation that is causing memory leak problems. I'm passing data to a driver, and unfortunately, the driver code is not something I can change, and it is written in C, so it deals with the data as a big BYTE array. Basically, the driver expects a struct, followed immediately in memory by a big chunk of raw...
2
1507
by: Mario Ceresa | last post by:
Hello everybody: I'd like to use the pickle module to save the state of an object so to be able to restore it later. The problem is that it holds a list of other objects, say numbers, and if I modify the list and restore the object, the list itself is not reverted to the saved one, but stays with one element deleted. An example session is...
6
391
by: Gaijinco | last post by:
I'm trying to do a template class Node. My node.hpp is: #ifndef _NODE_HPP_ #define _NODE_HPP_ namespace com { namespace mnya { namespace carlos { template <typename T>
2
3340
by: presencia | last post by:
Hi everyone, I have written a small program running fine until a Segmentation fault. Using a debugger I have localized the function the fault happens in. The Signal appears during a call to delete in the recursive function I have posted below. I have done some C coding before but I am fairly new to C++. I would really appreciate any help. I can't...
0
7920
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8347
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5394
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3844
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.