Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Quotes (And don't give me single quote example)

Status
Not open for further replies.
Apr 3, 2003
12
US
I was doing search on net, and I can't anywhere how to insert a string with quotes into SQL using ASP.

Ok I know how to use single quotes
Replace(String,"'","''") And don't say it's the same for double quotes because it doesn't work.

Replace(String,""","""") does not work.

I even tried Replace(String,CHR(34),CHR(34) & CHR(34)), no errors but doesn't work.

I know how to use it in an asp string. Response.Write "blah blah said, "" This aand that and variable of " & Var & """. yeah that's what he said"

I know all that.

I just want to know now to take

String = 64" x 32" of round wood

Now insert that into a SQL statement. Only the variable String is coming from a form.

INSERT INTO Table (field) VALUES('" & ???WHAT??? & "')"
 
Ok why does the main forum show I have 10 replies but I don't see any.
 
I think you may be trying to over-complicate things here:

Code:
strVal = Request.Form("val")
' eg: 64" x 32" of round wood

strSQL = "INSERT INTO table (field) VALUES ('" & strVal & "')"

This gives a SQL result of:
INSERT INTO table (field) VALUES ('64" x 32" of round wood')
which is perfectly valid. --James
 
Hmm.. well that's what I have but when I do SQL Query, and look it up it only has 64 in the field.


This is what I have, simplified anyway.

Note: Request.Form("ProdDescript") = 64" x 32" of round wood

Code Looks like this:

tmpProdDes = Replace(Request.Form("ProdDescript"),"'","''")

SQL = SQL & "INSERT INTO tblJKWorkOrder "
SQL = SQL & "(ProdDescript) "
SQL = SQL & " VALUES("
SQL = SQL & "'" & tmpProdDes & "')"



Maybe I'm just missing something, because I 100% agree with you that ' 64" ' should work just fine. I guess I'll have to double check here and there to make sure I'm not missing anything.
 
could you post the line you use to display the result. I think the " just somehow messes up your HTML display only.
 
Try printing out the value your receiving from your form to make sure your really receiving the whole string. One common cause of string cutoffs like that is that your input from the previous page could have the value filled from ASP and you didn't put quotes around that value in the html correctly. Ie, in this case you would have to either use single quotes after the value= or to use normal quotes but replace interior quotes with escape characters.

-Tarwn [sub]01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101 [/sub]
[sup]29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19[/sup]
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top