Solved

ASP and SQL

Posted on 2004-09-10
4
206 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
Moving your enterprise fax infrastructure from in-house fax machines and servers to the cloud makes sense — from both an efficiency and productivity standpoint. But does migrating to a cloud fax solution mean you will no longer be able to send or re…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

756 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