SuperKlutz
Technical User
On an .asp page, I have a form set up to add users to a database. The form includes fields for username and password. When I try to add the user, I get the following error statement:
Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in INSERT INTO statement.
/manage/confirmuser.asp, line 37
If I just insert the username, it works fine, but when I add the password, I get the error. Please look at my code and tell me what's wrong!
Code:
dim myConn
dim cnString
dim filePath
dim username, password, confirmpassword
username = Request.Form("username"
password = Request.Form("password"
confirmpassword = Request.Form("confirmpassword"
If username = "" or password = "" then
Response.Write("<h5><font color=""red"">You must enter a username and password." _
& " Click your browser's Back button and enter all the" _
& " required information.</font></h5>"
elseif password <> confirmpassword then
Response.Write("<h5><font color=""red"">The password and confirm password fields" _
& " do not match. Click your browser's Back button and" _
& " re-enter the information.</font></h5>"
else
Set myConn = server.CreateObject("ADODB.Connection"
filePath = Server.MapPath("partners.mdb"
cnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & filePath
dim strSQL
strSQL = "INSERT INTO tblUsers(userName, password) Values('" & username & "', '" & password & "');"
myConn.Open cnString
myConn.Execute strSQL,,adExecuteNoRecords
Response.Write("<h5><font color=""GREEN"">User " & username & " has been added.</font></h5>"
Response.Write("Click <a href=""adduser.asp"">here</a> to add" _
& " another user, or <a href=""managemenu.asp"">here</a>" _
& " to return to the menu."
myConn.Close
Set myConn = nothing
end if
%>
Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in INSERT INTO statement.
/manage/confirmuser.asp, line 37
If I just insert the username, it works fine, but when I add the password, I get the error. Please look at my code and tell me what's wrong!
Code:
dim myConn
dim cnString
dim filePath
dim username, password, confirmpassword
username = Request.Form("username"
password = Request.Form("password"
confirmpassword = Request.Form("confirmpassword"
If username = "" or password = "" then
Response.Write("<h5><font color=""red"">You must enter a username and password." _
& " Click your browser's Back button and enter all the" _
& " required information.</font></h5>"
elseif password <> confirmpassword then
Response.Write("<h5><font color=""red"">The password and confirm password fields" _
& " do not match. Click your browser's Back button and" _
& " re-enter the information.</font></h5>"
else
Set myConn = server.CreateObject("ADODB.Connection"
filePath = Server.MapPath("partners.mdb"
cnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & filePath
dim strSQL
strSQL = "INSERT INTO tblUsers(userName, password) Values('" & username & "', '" & password & "');"
myConn.Open cnString
myConn.Execute strSQL,,adExecuteNoRecords
Response.Write("<h5><font color=""GREEN"">User " & username & " has been added.</font></h5>"
Response.Write("Click <a href=""adduser.asp"">here</a> to add" _
& " another user, or <a href=""managemenu.asp"">here</a>" _
& " to return to the menu."
myConn.Close
Set myConn = nothing
end if
%>