Sunday 15 August 2010

sql - Trying to insert data into database after uploading image, syntax error in ASP Classic and VBscript -



sql - Trying to insert data into database after uploading image, syntax error in ASP Classic and VBscript -

i trying insert record access database after uploading image. image save correctly cant insert command work.

class="lang-vbs prettyprint-override">set o = new clsupload if o.exists("cmdsubmit") 'get client file name without path sfilesplit = split(o.filenameof("txtfile"), "\") sfile = sfilesplit(ubound(sfilesplit)) o.fileinputname = "txtfile" o.filefullpath = server.mappath("ads") & "\" & sfile o.save if o.error = "" response.write "success. file saved " & o.filefullpath & ". county = " & o.valueof("county") company = o.valueof("company") county = o.valueof("county") imgfile = sfile set objdbconnection = server.createobject("adodb.connection") objdbconnection.open "provider=microsoft.jet.oledb.4.0;data source=c:\users\user\desktop\websites\123justlistit\wwwroot\admin\123justlistit.mdb" set sqlins = server.createobject("adodb.command") sqlins.activeconnection = objdbconnection sqlins.commandtext="insert ads (company, county, image)values(?,?,?)" sqlins.parameters.append sqlins.createparameter("@company", advarchar, adparaminput, 25, company) sqlins.parameters.append sqlins.createparameter("@county", advarchar, adparaminput, 25, county) sqlins.parameters.append sqlins.createparameter("@imgfile", advarchar, adparaminput, 50, imgfile) sqlins.execute objdbconnection.close else response.write "failed due next error: " & o.error end if end if set o = nil

i getting:

class="lang-none prettyprint-override">microsoft jet database engine error '80040e14' syntax error in insert statement.

i think has trying insert filename of image not sure

two of parameter names (@company , @county) conflict column names. either alter parameter names different or (better) set identifiers in query string in square brackets:

sqlins.commandtext = "insert [ads] ([company], [county], [image]) values (?,?,?)"

using square brackets avoids problems identifiers containing spaces or conflicting reserved words.

sql vbscript asp-classic

No comments:

Post a Comment