Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

unterminated String Constant - Ugh!

Posted on 2004-10-26
14
Medium Priority
?
218 Views
Last Modified: 2008-02-01
I'm receiving an unterminated string constant for the following sql statement:

strSQL =  "SELECT siteID, name1, addr1a, city1, state1,zip1, from tblsite left join tblgroup
                                                                                          on tblsite.siteid=tblgroup.siteid left join tblphysgroup
                                                                                          on tblgroup.physid=tblphysgroup.physid left join tblphysician
                                                                                          on tblphysgroup.physid=tblphysician.physid where tblsite.siteid= " & strSpecialty & " order by tblsite.name1"

Can anyone show me where the error is?
0
Comment
Question by:johnson00
[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
  • 7
  • 3
  • 2
  • +2
14 Comments
 
LVL 15

Expert Comment

by:justinbillig
ID: 12414892
can you post teh exact value of strSQL
0
 
LVL 2

Author Comment

by:johnson00
ID: 12414912
All of that is what I'm attempting to set strSQL equal to.  
0
 
LVL 70

Expert Comment

by:Scott Pletcher
ID: 12414968
What datatype is strSpecialty?  Can it be concatenated directly to a string constant?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 15

Expert Comment

by:SRigney
ID: 12414977
You need a single quote around your value strSpecialty

strSQL =  "SELECT siteID, name1, addr1a, city1, state1,zip1, from tblsite left join tblgroup
                                                                           on tblsite.siteid=tblgroup.siteid left join tblphysgroup
                                                                           on tblgroup.physid=tblphysgroup.physid left join tblphysician
                                                                           on tblphysgroup.physid=tblphysician.physid where tblsite.siteid= '" & strSpecialty & "' order by tblsite.name1"


0
 
LVL 15

Expert Comment

by:SRigney
ID: 12414996
Also make sure the code is either all on one line, or you separate it with the underscore.

strSQL =  "SELECT siteID, name1, addr1a, city1, state1,zip1, from tblsite left join tblgroup " _
                & "on tblsite.siteid=tblgroup.siteid left join tblphysgroup " _
                & "on tblgroup.physid=tblphysgroup.physid left join tblphysician " _
                & "on tblphysgroup.physid=tblphysician.physid where tblsite.siteid= '" _
                & strSpecialty & "' order by tblsite.name1"
0
 
LVL 2

Author Comment

by:johnson00
ID: 12415244
Well, now I get this error:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.
0
 
LVL 15

Expert Comment

by:SRigney
ID: 12415413
Can you show us the value of strSQL when it is attempting to run?

Is SiteID an int field or a character field?

Since it's Access (instead of my assumed SQL Server) you may just need to end with a semi-colon.

& strSpecialty & "' order by tblsite.name1;"
0
 
LVL 2

Author Comment

by:johnson00
ID: 12415456
SiteID is an int field.  I can't get far enough to output what the sql statement gives me.  It won't execute past it, but just keeps erring on the line.  Well, this is actually an ASP page that contains a SQL reference to a table to select data.  It's worth a shot.  I'm getting desperate and frustrated.
0
 
LVL 2

Author Comment

by:johnson00
ID: 12415460
doesn't like the semi colon either.
0
 
LVL 2

Author Comment

by:johnson00
ID: 12415476
Ok, I have a new error now:

Syntax error in FROM clause.
0
 
LVL 2

Author Comment

by:johnson00
ID: 12415760
Here is the output of the SQL statement:

SELECT siteID, name1, addr1a, city1, state1 from tblsite left join tblgroupon tblsite.siteid=tblgroup.siteid left join tblphysgroupon tblgroup.physid=tblphysgroup.physid left join tblphysicianon tblphysgroup.physid=tblphysician.physid where tblsite.siteid= '' order by tblsite.name1;
0
 
LVL 2

Author Comment

by:johnson00
ID: 12416032
Where should I look from here?
0
 
LVL 6

Expert Comment

by:PePi
ID: 12416296
SELECT siteID, name1, addr1a, city1, state1 from tblsite left join tblgroupon .... you forgot to put a space between tblgroup and ON

also for

tblphysgroupon ... should be tblphysgroup ON
tblphysicianon... should be tblphysician ON


HTH!!!
0
 
LVL 6

Accepted Solution

by:
PePi earned 2000 total points
ID: 12416361
also i found this

SELECT siteID, name1, addr1a, city1, state1,zip1, ...


remove the comma after zip1 field
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

618 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