Syntax Error on SQL statement

D

dthmtlgod

I am getting a syntax error on my SQL statement, not sure if I am doing this
right. i am trying to pass a value from another form.

strsql = "select PrinterModel, PrinterName, IP_Address, Location from
Printers where PrinterName = ' & <% =Request.Form(npName) %> & ')"
 
B

Bob Barrows [MVP]

dthmtlgod said:
I am getting a syntax error on my SQL statement, not sure if I am
doing this right. i am trying to pass a value from another form.

strsql = "select PrinterModel, PrinterName, IP_Address, Location from
Printers where PrinterName = ' & <% =Request.Form(npName) %> & ')"

You have a closing parenthesis without an opening parenthesis. Using

response.write strsql

would make this easy to see.



Bob Barrows
 
C

CJM

dthmtlgod said:
I am getting a syntax error on my SQL statement, not sure if I am doing this
right. i am trying to pass a value from another form.

strsql = "select PrinterModel, PrinterName, IP_Address, Location from
Printers where PrinterName = ' & <% =Request.Form(npName) %> & ')"

Try:

strsql = "select PrinterModel, PrinterName, IP_Address, Location from
Printers where PrinterName = ' " & Request.Form(npName) & " ' "

I've put spaces around the single quotes for clarity, but you can remove
them in your code.

CJM
 
D

dthmtlgod

OK. Thank you Bob.

That corrected the syntax error problem, however, it is not recognizing the
=Request.Form(npName) value. Do I need to set this as a value and pass it?
 
D

dthmtlgod

CJM,

That is giving me the below error

Error Type:
Request object, ASP 0102 (0x80004005)
The function expects a string as input.
 
D

dthmtlgod

Nevermind, I figured it out myself.

Needs quotes around ("npName")

Should have caught that in the first place.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top