...

View Full Version : admin script



sagat
08-29-2004, 10:55 PM
i have a basic admin script that allows you to add, delete and update user. I have an error with the add script:

<%

Set conn = server.createobject("adodb.connection")
DSNtemp = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("netteh.mdb")
conn.Open DSNtemp

'here we are determining which form its from and getting the info from the form
'the first two represent the user form
'we will use this to add to the database
If Request.Form("T1") > "" Then
Username= Request.Form("T1")
Password = Request.Form("T2")
Else
Username = Request.Form("T3")
Password= Request.Form("T4")
End If

If Request.Form("T1") > "" Then
SQL = "Insert INTO Students(Username,Password) Values ('" & Username & "','" & Password& "')"
Else
SQL = "Insert INTO admin (Username,Password) Values ('" & Username & "','" & Password & "')"
End If
Conn.Execute(SQL)
Conn.Close
Response.Redirect "admin2.asp"
%>

Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in INSERT INTO statement.
/TMP7jgep38a0v.asp, line 23


Line 23:
If Request.Form("T1") > "" Then
SQL = "Insert INTO Students(Username,Password) Values ('" & Username & "','" & Password& "')"
Else
SQL = "Insert INTO admin (Username,Password) Values ('" & Username & "','" & Password & "')"
End If

Do you guys have a better admin script? i would like one that has user levels and be able to delete, add and updat users. thanks in advance

BuddhaMan
08-30-2004, 01:43 AM
I don't have an admin script, but you could use the SQL statement editor in Access to work out the kinks in your SQL statement. Once you get it to work with live data, transfer it over to you code and replace the values with your variables and 'codify' it.

glenngv
08-30-2004, 05:35 AM
Username and/or Password are reserved words in Access. Try renaming them.

whammy
09-01-2004, 03:17 AM
I agree with Glenn... specifically, password is DEFINITELY a reserved word in Access (I know this from previous experience).

If you're using SQL Server you can get around that by using brackets [] around the offending field name.

If you're using access, you might just want to use "pass" instead of password. I don't think "username" is a reserved word (I could be wrong!), but it's a good practice to not use really common computer names for database fields. They *should* be descriptive, however! :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum