navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

# in variable used in SQL?

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> # in variable used in SQL?
Page: [1]
 
sgreen0

 

Posts: 726
From: Long Beach, CA, USA
Status: offline

 
# in variable used in SQL? - 9/30/2005 15:03:30   
I need to query a table for a field with a # sign in it. As a example, one of the fields contains:

Lyric Lab #3 - Rhyme Assignment

My SQL includes:

WHERE AssignmentInfo.AssignmentName = " & vAssignmentName

VAssignmentName would contain "Lyric Lab #3 - Rhyme Assignment"

the Query generates an error and the WHERE clause looks like this:

'AssignmentInfo.AssignmentName = Lyric Lab'

That implies to me that it is cutting off everything after the # sign.

Is there something I can do about this?

Stephen
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: # in variable used in SQL? - 9/30/2005 15:51:48   
What is your actual SQL string?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to sgreen0)
sgreen0

 

Posts: 726
From: Long Beach, CA, USA
Status: offline

 
RE: # in variable used in SQL? - 9/30/2005 16:18:07   
Spooky!

The query looks like this:

SELECT OnLineContacts.ID, OnLineRegistration.CourseID, OnLineRegistration.EvalId, OnLineEvaluators.LastName, OnLineEvaluators.FirstName, OnLineEvaluators.Email, AssignmentInfo.AssignmentID, AssignmentInfo.AssignmentName, AssignmentInfo.TableName, AssignmentResultsSummary.DateTaken, AssignmentResultsSummary.DateGraded, AssignmentResultsSummary.Grade, AssignmentResultsSummary.Notes, AssignmentResultsSummary.Retake, AssignmentResultsSummary.Pass FROM OnLineEvaluators INNER JOIN ((OnLineContacts INNER JOIN OnLineRegistration ON OnLineContacts.ID = OnLineRegistration.ID) INNER JOIN (AssignmentInfo INNER JOIN AssignmentResultsSummary ON AssignmentInfo.AssignmentID = AssignmentResultsSummary.AssignmenttID) ON OnLineContacts.ID = AssignmentResultsSummary.ID) ON OnLineEvaluators.EvalID = AssignmentResultsSummary.EvalID WHERE AssignmentInfo.AssignmentName = Lyric Lab


The last part *should* read "Lyric Lab #3 - Rhyme Assignment"

I should mention that the Assignment Name comes from a querystring passed in the link from the previous page. When I hover over that link I can see that it reads "View_Assignment.asp?AssignmentName=Lyric Lab #3 - Rhyme Assignment"

Thanks for you help.

Stephen

(in reply to Spooky)
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: # in variable used in SQL? - 9/30/2005 16:21:08   
If its text - where are the quotes?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to sgreen0)
sgreen0

 

Posts: 726
From: Long Beach, CA, USA
Status: offline

 
RE: # in variable used in SQL? - 10/1/2005 2:44:52   
Good Point!

When I add single quotes around the variable thus:

fp_sQry="SELECT OnLineContacts.ID, OnLineRegistration.CourseID, OnLineRegistration.EvalId, OnLineEvaluators.LastName, OnLineEvaluators.FirstName, OnLineEvaluators.Email, AssignmentInfo.AssignmentID, AssignmentInfo.AssignmentName, AssignmentInfo.TableName, AssignmentResultsSummary.DateTaken, AssignmentResultsSummary.DateGraded, AssignmentResultsSummary.Grade, AssignmentResultsSummary.Notes, AssignmentResultsSummary.Retake, AssignmentResultsSummary.Pass FROM OnLineEvaluators INNER JOIN ((OnLineContacts INNER JOIN OnLineRegistration ON OnLineContacts.ID = OnLineRegistration.ID) INNER JOIN (AssignmentInfo INNER JOIN AssignmentResultsSummary ON AssignmentInfo.AssignmentID = AssignmentResultsSummary.AssignmenttID) ON OnLineContacts.ID = AssignmentResultsSummary.ID) ON OnLineEvaluators.EvalID = AssignmentResultsSummary.EvalID WHERE AssignmentInfo.AssignmentName = '" & vAssignmentName & "'"


I get this:

SELECT OnLineContacts.ID, OnLineRegistration.CourseID, OnLineRegistration.EvalId, OnLineEvaluators.LastName, OnLineEvaluators.FirstName, OnLineEvaluators.Email, AssignmentInfo.AssignmentID, AssignmentInfo.AssignmentName, AssignmentInfo.TableName, AssignmentResultsSummary.DateTaken, AssignmentResultsSummary.DateGraded, AssignmentResultsSummary.Grade, AssignmentResultsSummary.Notes, AssignmentResultsSummary.Retake, AssignmentResultsSummary.Pass FROM OnLineEvaluators INNER JOIN ((OnLineContacts INNER JOIN OnLineRegistration ON OnLineContacts.ID = OnLineRegistration.ID) INNER JOIN (AssignmentInfo INNER JOIN AssignmentResultsSummary ON AssignmentInfo.AssignmentID = AssignmentResultsSummary.AssignmenttID) ON OnLineContacts.ID = AssignmentResultsSummary.ID) ON OnLineEvaluators.EvalID = AssignmentResultsSummary.EvalID WHERE AssignmentInfo.AssignmentName = 'Lyric Lab'


Still missing everything beyond the #...

Stephen

(in reply to Spooky)
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: # in variable used in SQL? - 10/1/2005 8:03:27   
Sorry - should have read your reply more.
If its coming from a querystring then you should URLencode the string being passed. '#' has a special meaning as a bookmark in a hyperlink.

A check you can do for this sort of thing is to response.write the value passed from the previous page and see that it matches what you expect to get

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to sgreen0)
sgreen0

 

Posts: 726
From: Long Beach, CA, USA
Status: offline

 
RE: # in variable used in SQL? - 10/1/2005 14:14:45   
Thanks. That did the trick.

Stephen

(in reply to Spooky)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> # in variable used in SQL?
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts