vbscript sql strange error (1 Viewer)

swarv

Registered User.
Local time
Today, 11:02
Joined
Dec 2, 2008
Messages
196
Hi all,

I have this code:

Dim objConn, objRS, strQ, a, b, stsql, stuser, stpass, stadd, stpost, stfull

strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath("\test\example.mdb")
Set objconnection = Server.CreateObject("ADODB.Connection")
objconnection.Open strConnection

stuser = request.form("username")
stpass = request.form("password")
stfull = request.form("fullname")
stadd = request.form("add")
stpost = request.form("postcode")
strSQL = "INSERT INTO members(username, pass, fullname) VALUES('" & stuser & "','" & stpass & "','" & stfull & "')"
objConnection.Execute strSQL



which works fine apart from its not adding the stfull part to the database. any ideas anybody?


the form code is:

<tr align="center">
<td width="248" height="17" bgcolor="#C0C0C0" align="right"><font color="#000000"><small>Add
Your Full Name:</small></font></td>
<td height="17" width="123" bgcolor="#C0C0C0" align="left"><input type="text"
name="fullname" size="50" tabindex="3" maxlength="8"></td>
<td width="47" height="17" bgcolor="#C0C0C0" align="center"><a
href="javascript:alert('The password must be between 4 and 8 characters long.')"><small><small>Help</small></small></a></td>
</tr>



thanks

Martin
 

swarv

Registered User.
Local time
Today, 11:02
Joined
Dec 2, 2008
Messages
196
I did a response.write and got this:

INSERT INTO members(username, pass, add) VALUES('uytr','67456546','546')

SQL looks ok to me.
Can anybody shed any light on please as its driving me nuts

thanks

Martin
 

LPurvis

AWF VIP
Local time
Today, 11:02
Joined
Jun 16, 2008
Messages
1,269
The Jet OLEDB provider is more sensitive to reserved words than Access or DAO.
You need to escape all of yours.
I presume you're providing a cut down version of your code? You pass five values to your form - and only insert 3?

Assuming you actually have:
INSERT INTO members(username, password, fullname, add, postcode)

You'd need:
INSERT INTO members([username], [password], fullname, [add], postcode)

Cheers
 

Users who are viewing this thread

Top Bottom