I am a newsbie to ASP but need to get a script together that will insert the
Windows Username of the local machine into an access database.
I get the errors from my code below, can anyone help me please as I've hit a
deadend:
Thanks
CODE:
<% @ Language="VBScript" %>
<%'force authentication- put this at top of ASP code
If Request.ServerVariables("LOGON_USER") = "" Then
Response.Status = "401 access denied"
End If
Username=(Request.ServerVariables("LOGON_USER"))
'declare variables
dim connection
dim sSQL,sConnString
'declare SQL statement that will query the database
sSQL="INSERT INTO Log (Name) VALUES (Username)"
'define the connection string, specify database
' driver and the location of database
sConnString="DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Server.MapPath("ServerLog.mdb") & ";"
'create an ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")
'Open the connection to the database
connection.Open(sConnString)
'execute the SQL
connection.execute(sSQL)
'check to see if there were any errors
If err.number=0 Then
response.write "the data was inserted successfully."
Else
response.write "there was a problem entering the data."
End If
'close the object and free up resources
Connection.Close
Set Connection = Nothing
%>