Print Page | Close Window

Server variables

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=7343
Printed Date: 30 March 2026 at 12:17pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Server variables
Posted By: Micah
Subject: Server variables
Date Posted: 17 November 2003 at 5:49pm
I am trying to find a way to store 3 server variables into an Access database.  I created the database, I know the names of the variables I want, but I need help in simply adding the variables to the database.  My first attempt at this, so please don't mock. 



Replies:
Posted By: Gullanian
Date Posted: 17 November 2003 at 5:56pm
Click ASP at the top of this page, then go the bottom for some tutorials on this.


Posted By: Micah
Date Posted: 17 November 2003 at 9:16pm

In the examples, you are reading in from a form.  If I just want to use server variables, I made the changes to the below text.  I am getting the well-known "database or object is read-only" error.  The database I am using is in the "db" directory on my brinkser account and I know the directory is fine because my other database is working fine.  If anyone spots the error right away, please let me know.

Micah

'Dimension variables
Dim adoCon               'Holds the Database Connection Object
Dim newStats    'Holds the recordset for the new record to be added
Dim strSQL               'Holds the SQL query to query the database

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/stat.mdb")

'Create an ADO recordset object
Set newStats = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tble.remoteAddress, tble.httpReferrer, tble.httpUserAgent FROM tble;"

'Set the cursor type we are using so we can navigate through the recordset
newStats.CursorType = 2

'Set the lock type so that the record is locked by ADO when it is updated
newStats.LockType = 3

'Open the recordset with the SQL query
newStats.Open strSQL, adoCon

'Tell the recordset we are adding a new record to it
newStats.AddNew

'Add a new record to the recordset
newStats.Fields("remoteAddress") = Request.ServerVariables("REMOTE_ADDR")
newStats.Fields("httpReferrer") = Request.ServerVariables("HTTP_REFERER")
newStats.Fields("httpUserAgent") = Request.ServerVariables("HTTP_USER_AGENT")

'Write the updated recordset to the database
newStats.Update

newStats.Close
Set newStats = Nothing
Set adoCon = Nothing

%>



Posted By: ljamal
Date Posted: 17 November 2003 at 9:33pm
Update the permissions on the database to give write access to the IUSER account.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net