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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vb script compilation error while TRYING to write to db, URGENT

Status
Not open for further replies.

hemal666

Programmer
Dec 10, 2001
25
GB
hi,
im trying to wite some info to MS Access database with a DSNLess connection, i just cant seem to get past ther error!

heres the error:

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/registerinterest.asp, line 40

SQL ="INSERT INTO reginterest(fname,sname,hfno,add1,add2,pcode,daytel,evetel,mobtel,email,btoc,detreq)VALUES('"&fname&"','"&sname&"','"&**hfno&"','"&add1&"','"&add2&"','"&pcode&"','"&daytel&"','"&evetel&"','"&mobtel&"','"&email&"','"&btoc&"','"&detreq&"')"

*error points to **

im confused my connection stuff is as follows :
Code:
<%
Set Con=Server.CreateObject(&quot;ADODB.Connection&quot;)

Con.open &quot;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=&quot;&Server.MapPath(&quot;databases/pj.mdb&quot;)&&quot;;&quot;
'Con.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot;&Server.MapPath(&quot;databases/pj.mdb&quot;)&&quot;;&quot;
SQL =&quot;INSERT INTO reginterest(fname,sname,hfno,add1,add2,pcode,daytel,evetel,mobtel,email,btoc,detreq)VALUES('&quot;&fname&&quot;','&quot;&sname&&quot;','&quot;&hfno&&quot;','&quot;&add1&&quot;','&quot;&add2&&quot;','&quot;&pcode&&quot;','&quot;&daytel&&quot;','&quot;&evetel&&quot;','&quot;&mobtel&&quot;','&quot;&email&&quot;','&quot;&btoc&&quot;','&quot;&detreq&&quot;')&quot;

Set ipRS=Server.CreateObject(&quot;ADODB.Recordset&quot;)
ipRS.open , SQL , Con

%>
any help will be much appreciated :) Hemal
 
yup all values are strings in the database and ive tried spacing them too!!!
still no JOY!!!!!!!
 
You statement falls over when you try to use the variable &quot;hfno&quot;, maybe this is reserved or something, just change the variable name to something else.

BDC.
 
Consider using AddNew (as in ipRS.AddNew). Then your code will error out on the individual column insert, instead of a long SQL command.

Set RS = Server.CreateObject(&quot;ADODB.RecordSet&quot;)
SQL = &quot;SELECT * FROM table1&quot;
RS.Open SQL,Conn,2,3
RS.AddNew
RS(&quot;fname&quot;) = fname
RS(&quot;sname&quot;) = sname
RS(&quot;hfno&quot;) = hfno
RS(&quot;add1&quot;) = add1
RS.Update
RS.Close
conn.close
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top