|
 |
asp_web_howto thread: what am i doing wrong?
Message #1 by "tommy angel" <tommy_angel@u...> on Mon, 25 Jun 2001 22:32:08
|
|
i have this code :
<html>
Dim adoCon 'Database Connection Variable
Dim adoRec 'Database Recordset Variable
Dim strAccessDB 'Holds the Access Database Name
Dim strSQL
Dim strIp
Dim strPagina
Dim strRefer
Dim strBrowser
Dim strvTime
Dim strvDate
'Error Trapping
On Error Resume Next
'Initalise the strUserName variable
strIp = Request.ServerVariables("REMOTE_ADDR")
strPagina = Request.ServerVariables("SCRIPT_NAME")
strRefer = Request.ServerVariables("HTTP_REFERER")
strBrowser = Request.ServerVariables("HTTP_USER_AGENT")
strvTime = request.servervariables("Time")
strvDate = request.ServerVariables("Date")
'Initialise the strAccessDB variable with the name of the Access Database
strAccessDB = "VisitorInfo" 'database name
'Create a connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
Set adoRec = Server.CreateObject("ADODB.Recordset")
'Open connection to the database adoCon="DRIVER={Microsoft Access Driver
(*.mdb)};uid=;"
'Open Connection to database
adoCon = adoCon & "DBQ=" & server.mappath(strAccessDB)
strSQL = "INSERT INTO tblInfo(vip, vpagina, vreferer, vbrowser, vtime,
vdate) VALUES(" & strIp & ", " &strPagina & ", "& strRefer & ", " &
strBrowser & ", " & strvTime & "," & strvDate & ")"
'Query the database
adoRec.Open strSQL, adoCon
'Close Objects
Set adoCon = Nothing
Set adoRec = Nothing
<body>
</html>
why doesn't it inserts anything?
Message #2 by "Vince Kavanagh" <vince@6...> on Mon, 25 Jun 2001 23:16:44 +0100
|
|
I'm assuming that these lines;
'Open connection to the database adoCon="DRIVER={Microsoft Access Driver
(*.mdb)};uid=;"
are actually;
'Open connection to the database
adoCon="DRIVER={Microsoft Access Driver(*.mdb)};uid=;"
For debugging purposes I would try the following;
1. Temporally remove the "On Error Resume Next".
2. Put your SQL into a Response.Write so you can see what is being produced.
Comment out this line: adoRec.Open strSQL, adoCon
and write: Response.Write strSQL
Best Regards,
Vince.
-----Original Message-----
From: tommy angel [mailto:tommy_angel@u...]
Sent: 25 June 2001 22:32
To: ASP Web HowTo
Subject: [asp_web_howto] what am i doing wrong?
i have this code :
<html>
Dim adoCon 'Database Connection Variable
Dim adoRec 'Database Recordset Variable
Dim strAccessDB 'Holds the Access Database Name
Dim strSQL
Dim strIp
Dim strPagina
Dim strRefer
Dim strBrowser
Dim strvTime
Dim strvDate
'Error Trapping
On Error Resume Next
'Initalise the strUserName variable
strIp = Request.ServerVariables("REMOTE_ADDR")
strPagina = Request.ServerVariables("SCRIPT_NAME")
strRefer = Request.ServerVariables("HTTP_REFERER")
strBrowser = Request.ServerVariables("HTTP_USER_AGENT")
strvTime = request.servervariables("Time")
strvDate = request.ServerVariables("Date")
'Initialise the strAccessDB variable with the name of the Access Database
strAccessDB = "VisitorInfo" 'database name
'Create a connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
Set adoRec = Server.CreateObject("ADODB.Recordset")
'Open connection to the database adoCon="DRIVER={Microsoft Access Driver
(*.mdb)};uid=;"
'Open Connection to database
adoCon = adoCon & "DBQ=" & server.mappath(strAccessDB)
strSQL = "INSERT INTO tblInfo(vip, vpagina, vreferer, vbrowser, vtime,
vdate) VALUES(" & strIp & ", " &strPagina & ", "& strRefer & ", " &
strBrowser & ", " & strvTime & "," & strvDate & ")"
'Query the database
adoRec.Open strSQL, adoCon
'Close Objects
Set adoCon = Nothing
Set adoRec = Nothing
<body>
</html>
why doesn't it inserts anything?
Message #3 by "TomMallard" <mallard@s...> on Tue, 26 Jun 2001 04:53:06 -0700
|
|
There aren't any single quotes surrounding the strings so sql will think
they're variables unless they are numeric...
strSQL = "INSERT INTO tblInfo(vip,vpagina,vreferer,vbrowser,vtime,vdate)
VALUES('" & strIp & "','" &strPagina & "','"& strRefer & "','" & strBrowser
& "','" & strvTime & "','" & strvDate & "')"
Use response.write strSQL to check your statement, it can be pasted into a
query if you use view-->sql after the query is open.
tom
Message #4 by "Sertial, Sam" <2495XX2@a...> on Tue, 26 Jun 2001 17:15:20 -0400
|
|
I think the time should be between #time#.
-----Original Message-----
From: tommy angel [mailto:tommy_angel@u...]
Sent: Monday, June 25, 2001 6:32 PM
To: ASP Web HowTo
Subject: [asp_web_howto] what am i doing wrong?
i have this code :
<html>
Dim adoCon 'Database Connection Variable
Dim adoRec 'Database Recordset Variable
Dim strAccessDB 'Holds the Access Database Name
Dim strSQL =09
Dim strIp =09
Dim strPagina =09
Dim strRefer =09
Dim strBrowser =09
Dim strvTime =09
Dim strvDate =09
'Error Trapping
On Error Resume Next
'Initalise the strUserName variable
strIp =3D Request.ServerVariables("REMOTE_ADDR")
strPagina =3D Request.ServerVariables("SCRIPT_NAME")
strRefer =3D Request.ServerVariables("HTTP_REFERER")
strBrowser =3D Request.ServerVariables("HTTP_USER_AGENT")
strvTime =3D request.servervariables("Time")
strvDate =3D request.ServerVariables("Date")
'Initialise the strAccessDB variable with the name of the Access
Database
strAccessDB =3D "VisitorInfo" 'database name
'Create a connection odject
Set adoCon =3D Server.CreateObject("ADODB.Connection")
Set adoRec =3D Server.CreateObject("ADODB.Recordset")
'Open connection to the database adoCon=3D"DRIVER=3D{Microsoft Access
Driver
(*.mdb)};uid=3D;"
'Open Connection to database
adoCon =3D adoCon & "DBQ=3D" & server.mappath(strAccessDB)
strSQL =3D "INSERT INTO tblInfo(vip, vpagina, vreferer, vbrowser,
vtime,
vdate) VALUES(" & strIp & ", " &strPagina & ", "& strRefer & ", " &
strBrowser & ", " & strvTime & "," & strvDate & ")"
'Query the database
adoRec.Open strSQL, adoCon
'Close Objects
Set adoCon =3D Nothing
Set adoRec =3D Nothing
<body>
</html>
why doesn't it inserts anything?
Message #5 by "tommy angel" <tommy_angel@u...> on Wed, 27 Jun 2001 13:33:06
|
|
i already have found it,
i was using the wrong table :)
thanx anyways for the help
|
|
 |