Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP and SQL

Posted on 2004-09-10
4
Medium Priority
?
209 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 96

Accepted Solution

by:
Lee W, MVP earned 200 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

Take our survey for a chance to win!

As a valued customer of Targus, we’d like to ask you a few questions about us. As thanks, you will be automatically entered for a chance to win a $500 VISA gift card. To enter, just complete the survey by September 15, 2017.

Question has a verified solution.

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

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…
Arrow Electronics was searching for a KVM  (Keyboard/Video/Mouse) switch that could display on one single monitor the current status of all units being tested on the rack.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

719 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