Click to See Complete Forum and Search --> : Inserting double quotes into Access database


chrscote
02-17-2009, 08:37 AM
I am having trouble with using the double-quotes in an Access query. I know that I am supposed to double up the double-quotes to escape them, but I'm not sure if I'm doing it correctly. Below is the code I currently have. The h, l, and w items are height, length, and width which could have the inch mark (") in them. Can someone please tell me what I'm doing wrong in this part of the script?



partNum = Request.Form("partNum")
partName = Request.Form("partName")
NSN = Request.Form("nsn")
vendorID = Request.Form("vendorId")
h = Request.Form("height")
h = Replace(h, """", """""")
w = Request.Form("width")
w = Replace(w, """", """""")
l = Request.Form("length")
l = Replace(l, """", """""")
wt = Request.Form("weight")
uIss = Request.Form("UI")
unitCost = Request.Form("unitCost")
esd = Request.Form("esd")
hazmat = Request.Form("hazmat")
notes = Request.Form("notes")
eol = Request.Form("EOL")
eolDate = Request.Form("eolDate")
phstID = Request.Form("phst")
stowID = Request.Form("stowage")

sSql = "INSERT INTO dbo_tblPart ([number], partName, NSN, height, width, length, weight, unitOfIssue, unitCost, esd, hasmat, notes, imgName) "
sSql = sSql & " VALUES ('"&partNum&"','"&partName&"','" & NSN & "','"&h&"','"&w&"','"&l&"','"&wt&"','"& uIss & "','" & unitCost & "'," & esd & "," & hazmat & ",'" & notes & "'"

From what I can see, it appears that I am escaping them correctly.

Chris

ryanbutler
02-17-2009, 02:51 PM
Best chance is to response write your sql variable on the screen to see what's actually being inserted (instead of just eye balling it). Usually from there, it's just a matter of tweaking the escape sequences for a few minutes. I still never get them right the first time around.