Solved

ASP and SQL

Posted on 2004-09-10
4
204 Views
Last Modified: 2010-04-26
I'm trying to run a SQL statment, mixed with some VBScript. HEre is my code:

DIM mySQL
mySQL = "select  empid from a_employee" & _
        "where empfirstname + ' ' + emplastname = " & " ' " & Tim Tester " ' "
MyConn.Execute mySQL

When I try and submit the asp page, it comes back and tells me that it doesn't like the + sign. If I were doing this in a SQL Query window, it works fine...see my regular sql statement below. But for some reason, ASP doesn't like it.

select  empid, empfirstname, emplastname from a_employee
where empfirstname + ' ' + emplastname = 'Tim Tester'

Any ideas?
0
Comment
Question by:ONYX
4 Comments
 
LVL 95

Accepted Solution

by:
Lee W, MVP earned 50 total points
ID: 12030610
If that's an exact copy and paste of what you have, then you are missing a space at the beginning of "where" or the end of "a_employee" and I assume this:
& Tim Tester " ' "
is actually a variable used here.  Otherwise, I'm sure you know it should look like
& "Tim Tester" & "'" (although, there's no need to seperate out the quotes from the text).

If you can, have it echo back the SQL line, then cut and paste it into the SQL Query area to execute it outside the script.  It may shed some light on your problem.
0
 
LVL 2

Expert Comment

by:JuergenHartl
ID: 12039601
If you are using an Access database create the query in access and have a look at the SQL statement inj SQLView.
0
 
LVL 3

Expert Comment

by:Fairco
ID: 12043239
leew answered the most interesting part of the query. But there's another error. You need to add an additional space in the text at the line break!
So the following line
  "select  empid from a_employee" & _
should be
  "select  empid from a_employee " & _

This is very important, because your text currently merges the "a_employee" and the "where" phrase together, resulting "a_employeewhere", which is not understood by the SQL engine.
I also recommend to echo back the "mySQL" variable for debugging. In ASP use the "Response.write mySQL" statement to achieve this.
(By the way, why is this problem related to any hardware?)
0
 

Author Comment

by:ONYX
ID: 12045035
Thanks for all the replies. Indeed, it was a space that I was missing. Sorry for posting this in the 'hardware' section...my mistake.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Monitor input from a computer is usually nothing special.  In this instance it prevented anyone from using the computer.  This was a preconfiguration that didn't work.
This paper addresses the security of Sennheiser DECT Contact Center and Office (CC&O) headsets. It describes the DECT security chain comprised of “Pairing”, “Per Call Authentication” and “Encryption”, which are all part of the standard DECT protocol.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question