[WEB4LIB] SQL/ASP query

William Barnes wbarnes at husky.bloomu.edu
Wed Oct 4 08:13:45 EDT 2000


Ian, Are you using VBscript?

If so, here's how I do a SQL statement.
This is an example original statement:

select callnumber, title, create_date, create_operator from tblbook, tblcatalogers
where tblbook.opid = tblcatalogers.opid
and tblbook.callnumber >= "M" and tblbook.callnumber <="MZ"
order by tblbook.create_date

To do this in VBscript, I would do the following:

sql = "select callnumber, title, create_date, create_operator from tblbook, tblcatalogers"
sql = sql + "where tblbook.opid = tblcatalogers.opid"
sql = sql + "and tblbook.callnumber >= 'M' and tblbook.callnumber <='MZ' "
sql = sql + "order by tblbook.create_date"

set cursor = Conn.Execute (sql)

Notice anything "quoted" before in direct SQL is in single quotes in Vbscript.
(which is typically just Text fields you want to search on.)

A good web site for information is:
http://www.activeserverpages.com/learn/

It basically rocks.  I learned a lot from reading the sample code and it helped me write some pretty nice web applications.

If you need any more help, just drop me an e-mail.

Thanks!
--Bill
*******************************************
*  Bill Barnes, CNA, MCP, A+
*  Library Network Administrator
*  Harvey A. Andruss Library
*  Bloomsburg University
*  AL 125
*  ph: 570-389-2813
*  fax: 570-389-3895
*  e-mail: wbarnes at bloomu.edu
*******************************************


>>> Ian Winship <ian.winship at unn.ac.uk> 10/04/00 07:43AM >>>
I am trying to produce some asp scripts to search an Access database, but am
having difficulty getting the syntax right in the SQLQuery = "Select...
statement when I want to use AND, OR to require more than one match in the
same field. I am also a little unclear about the placing of single and
double quotation marks in the statement. 

I have not found any SQL or ASP books or Web sites that state clearly the
syntax. Can anyone point me to something useful for a beginner.

Thanks.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ian Winship
Learning Resources, University of Northumbria at Newcastle  
City Campus Library, Newcastle upon Tyne NE1 8ST, UK

                    ----------------       
e-mail: ian.winship at unn.ac.uk                
phone:  0191 227 4150      fax: 0191 227 4563 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 




More information about the Web4lib mailing list