I've been trying to get a login script written for my website to authenticate users, however I keep getting an error saying my syntax is incorrect (with regards to the Insert Into statement). I will say that this code is not mine, I got it from an article elsewhere on the web, however I cannot see what is wrong (I'm still new to this whole ASP thing). If anyone can offer any assistance, I'd really appreciate it.
Code follows:
------------------------
<html>
<head></head>
<body>
<%
Dim sSQL
Dim conn
Dim rs
set conn = Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.Recordset")
'Create a DSN less connection
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.ConnectionString = "Data Source =" & Server.MapPath("db/siterelated.mdb")
conn.Open
strSQL = "SELECT firstname,lastname FROM login"
set rs = conn.Execute (strSQL)
if (rs.BOF) and (rs.EOF) then
sSQL = "INSERT INTO login (firstname,lastname,username,password) Values " & _
"('" & Ucase(Request("firstname")) & _
"', '" & Request("lastname") & _
"', '" & Request("userid") & _
"', '" & Request("password") & "')"
conn.Execute sSQL,adCmdText
else
SQL = "DELETE * FROM login WHERE username = '" & Request.Form("userid")
conn.Execute SQL
end if
sSQL = "INSERT INTO login (firstname,lastname,username,password) Values " & _
"('" & Ucase(Request("firstname")) & _
"', '" & Request("lastname") & _
"', '" & Request("userid") & _
"', '" & Request("password") & "')"
conn.Execute sSQL,adCmdText
'close the recordset
rs.Close
set rs = Nothing
'close the connection
conn.Close
set conn = Nothing
%>
<font face="verdana">
<h2>Your login details have been saved to the database.</h2><br />
<a href="login.htm">Click here to access the login page!</a>
</body>
</html>
--------------------
The error is with line 28 (conn.Execute sSQL,adCmdText) and I have no clue what the deal is. Someone please help!!! ;)
-Josh