If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > SQL insert into problem with Quotes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-25-05, 18:45
baby_boomerang baby_boomerang is offline
Registered User
 
Join Date: Nov 2005
Posts: 13
SQL insert into problem with Quotes

Basically I have a drop down box and I want the variable to read the value selected from the drop down box.

Everything is working apart from I have to put quotes around each of the entry's in the box or the SQL will not work .

I am trying to say select * from table where company='value in box'

However I am unsure how I put quotes around the variable name?

I thought it was like this but it does not seem to work.
....company= "'" & variable & "'"

Sorry this is hard to explain.

Many Thanks in advance for any help.
BB
Reply With Quote
  #2 (permalink)  
Old 11-25-05, 19:25
fredservillon fredservillon is offline
Registered User
 
Join Date: Oct 2005
Posts: 178
Show me your connection string and the recordset statement your created, and I will fix it for you. HOw do you want to start the query, by button click or by change of value of your combox?

remember for the string var you use

RS.open "Select * from table where mystringfield ='" & StringVariable & "'", Connection

For numeric variable you use
RS.Open "Select * from table where mynumericfield =" & NumericVariable, COnnection

Last edited by fredservillon; 11-25-05 at 19:32.
Reply With Quote
  #3 (permalink)  
Old 11-27-05, 17:21
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
instead of this
Code:
RS.open "Select * from table where mystringfield ='" & StringVariable & "'", Connection
I would use...
Code:
quote = chr(34) 
RS.open "Select * from table where mystringfield =" & quote  & StringVariable & quote, Connection
otherwise you can have problems with words that have ' in them...

NOTE: I am not certain that 34 is the correct chr code... but it is pretty close...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On