Solved

ASP and SQL

Posted on 2004-09-10
4
200 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

this article is a guided solution for most of the common server issues in server hardware tasks we are facing in our routine job works. the topics in the following article covered are, 1) dell hardware raidlevel (Perc) 2) adding HDD 3) how t…
In this article we have discussed the manual scenarios to recover data from Windows 10 through some backup and recovery tools which are offered by it.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now