473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Run-time error 3075 - Syntax error in string in query expression VB6/MS-access

Hi,
I have an access db that I am trying to query from a vb6 program. I've the following code:
Dim sSQLQuery As String
sSQLQuery = "SELECT * FROM TblData WHERE ID = " & Chr(39) & ID & Chr(39)
ID here is equal to 1234567890

MsgBox sSQLQuery
the msgbox says: SELECT * FROM TblData WHERE ID = '1234567890 Note that the quotation is missing at the end

Set rs = db.OpenRecordset(sSQLQuery, dbOpenDynaset)
Here I get the error:
Run-time error '3075'
Syntax error in string in query expression 'ID='1234567890'.

Note that now there's a single quotes before ID (+ where's the rest of the sql string).

As a note, ID is not a numeric field in the access database. Its in as a text-field. Now here's the biggie: this code works for me in my development PC and the query returns with the data in the db. This started happening on another laptop that I installed this application on all of a sudden and I am unable to reproduce this on my PC.

Any help is appreciated.
Feb 13 '09 #1
4 11660
debasisdas
8,127 Expert 4TB
the following code

Expand|Select|Wrap|Line Numbers
  1. Dim sSQLQuery As String
  2. sSQLQuery = "SELECT * FROM TblData WHERE ID = '" &  ID & "'"
  3.  

it never happens that the same code will give different output on the same or any other system.
Feb 14 '09 #2
Hi.
Thanks for replying.

Chr(39) adds the quotation (') before and after ID. I also tried the quotation strings directly like you've suggested and i get the same result.

I agree that the same code will not give different results on different PCs. But, isn't it a possibility that my dev PC has some dependencies satisfied that a piece of code works alright on my PC, and the other PC is missing those dependencies. I don't think that is the case with this specific problem that I am having, but I just wanted to float that thought out.
Feb 14 '09 #3
debasisdas
8,127 Expert 4TB
Are you still getting the error after doing the way i suggested ?
Feb 14 '09 #4
It turned out that the ID that was returned from the source was null terminated and hence the quotation char could not be added.

Thanks for your responses.
Feb 14 '09 #5

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

Similar topics

3
by: leroybt.rm | last post by:
Can someone tell me how to run a script from a interactive shell I type the following: >>>python filename >>>python filename.py >>>run filename >>>run filename.py >>>/run filename >>>/run...
4
by: Ed | last post by:
Hello, I took a course in asp about 2 years ago and I was practicing with IIS 5.0. Then I put it down for a while. Now trying to get back to it. I can't run asp files from subdirectories of...
6
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
13
by: Bob Day | last post by:
Using vs2003, vb.net I start a thread, giving it a name before start. Code snippet: 'give each thread a unique name (for later identification) Trunk_Thread.Name = "Trunk_0_Thread" ' allow...
19
by: Bryan | last post by:
How can i run a bit of code straight from the IDE? Right now i make a temporary button and put the code behind that, then i run debug mode and click on the button. Is there a way to highlight...
9
by: Brett Wesoloski | last post by:
I am new to VS2005. I changed my program.cs file to be a different form I am working on. But when I go to run the application it still brings up the form that was originally declared as new. ...
7
by: Lee Crabtree | last post by:
I remember when I was first getting into .NET Forms programming that there was a rather emphatic rule about not constructing a form before calling Application.Run with it. So this: ...
8
by: David Thielen | last post by:
Hi; In our setup program how do I determine if I need to run "aspnet_regiis –i" and if so, is there an API I can calll rather than finding that program on the user's disk and calling it? --...
3
by: traceable1 | last post by:
Is there a way I can set up a SQL script to run when the instance starts up? SQL Server 2005 SP2 thanks!
7
by: mxdevit | last post by:
Task: run application from ASP.NET for example, you have a button on ASP.NET page, when press this button - one application is invoked. the code to run application (for example, notepad) is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.