Multiple ANDs

  • Thread starter Thread starter thsman
  • Start date Start date
T

thsman

Here is the query;
strSQL = ("SELECT * FROM bills WHERE sessionID = " & ThisSession & "
AND filename = '" & ThisFile & "' AND size = '" & ThisSize & "'")


sessionID is a number, filename is a string, size is also a string.

I'm getting this error "error '80004005'"

It is failing at this line of code

rsShopper.Open strSQL, adoCon

If I take out one of the AND conditions it works fine but obviously
that isn't what I want to do.

This is running from an asp page connecting to an Access mdb.

Here are the relevant lines of code;

strSQL = ("SELECT * FROM bills WHERE sessionID = " & ThisSession & "
AND filename = '" & ThisFile & "' AND size = '" & ThisSize & "'")

rsShopper.CursorType = 2

rsShopper.LockType = 3

rsShopper.Open strSQL, adoCon


Any help will be appreciated.

Bernie
 
You should display the result of the strSQL in a message box or to the
debug/immediate window (using Debug.Print) in order to see what's wrong with
it. One possibility would be that the value of either the filename or the
size has one or more single quote embedded in it or that the value of
ThisSession is null (ie., empty).
 
Thanks for the reply. I figured out a workaround that allows me to get
on with the project.

However, excuse my ignorance, what IDE would I need to be using to
have a debug/immediate window? I'm using Notepad 2 and while it color
codes fine it doesn't have such wondrous things.

Bernie
 
Maybe the same IDE as the one you're using for executing these pieces of
VB/VBA/VBScript code?
 
Ah, now we know that you are executing the pieces of code on a web server.
As you are testing/developping your application, nothing forbid you to add
the value of strSQL to the output of HTML code; for example with:

Response.Write sqlString & "<br>"
Response.Flush

' Uncomment the following line to stop the execution of the rest of the
page.
' Response.End


If your sqlString has special characters, you can choose to encode it:

Response.Write Server.HTMLEncode (sqlString) & "<br>"

With some IDEs like Visual Studio, Visual Interdev or Visual Studio.NET,
it's possible to put the web site into debug mode; even sometimes when the
web site is not local. Of course, this is all a configuration problem and I
don't know what your situation is for this web site.

Finally, for classic ASP, a better newsgroup to post this kind of question
would have be:

microsoft.public.inetserver.asp.db
microsoft.public.inetserver.asp.general

m.p.inetsdk.programming.scripting.vbscript could also be of interest to you.
 
Thanks. That is the kind of thing I've been doing. The site hasn't
gone live yet so I can do this with safety. This is a seat of the
pants one man in his home office type of operation.

Thanks again for your help.

Bernie
 
Back
Top