Link to home
Start Free TrialLog in
Avatar of Insomniac_PhD
Insomniac_PhD

asked on

Insert Statement Help

I am trying to insert a record into an access table using ASP.  What I have so far does not work.  There are no errors, but nothing gets inserted.



      x_AccessDate = date()
      x_AccessTime = time()
      x_AccessIP = Request.serverVariables("REMOTE_ADDR")

' Open connection to the database
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str

strsql = "INSERT INTO Log (AccessDate, AccessTime, AccessIP) VALUES (x_AccessDate, x_AccessTime, x_AccessIP)"

            Set rstemp = Server.CreateObject("ADODB.Recordset")
            'rstemp.Insert strsql, conn


conn.Close ' Close Connection
Set conn = Nothing
Avatar of Yrag1
Yrag1

Try this
            
dim Conn
set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open xDb_Conn_Str
dim strsql
strsql = "INSERT INTO Log (AccessDate, AccessTime, AccessIP) VALUES (x_AccessDate, x_AccessTime, x_AccessIP)"
Conn.Execute (strsql)
Conn.close
set Cconn = nothing

Gary
Avatar of fritz_the_blank
Try this instead:

strsql = "INSERT INTO Log (AccessDate, AccessTime, AccessIP) VALUES ('" & x_AccessDate & "', '" & x_AccessTime & "','" &  x_AccessIP & "')"


FtB
ASKER CERTIFIED SOLUTION
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can bypass all of the variables altogether like this:

' Open connection to the database
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str
strsql = "INSERT INTO Log (AccessDate, AccessTime, AccessIP) VALUES ('" & Date () & "', '" & Time() & "','" &  Request.serverVariables("REMOTE_ADDR") & "')"
conn.execute(strsql)
conn.close
set conn=Nothing


FtB
Avatar of Insomniac_PhD

ASKER

Thanks Fritz.
Glad to have helped,

FtB