Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Server variables
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Server variables

 Post Reply Post Reply
Author
Micah View Drop Down
Newbie
Newbie


Joined: 17 November 2003
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote Micah Quote  Post ReplyReply Direct Link To This Post Topic: Server variables
    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. 
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 17 November 2003 at 5:56pm
Click ASP at the top of this page, then go the bottom for some tutorials on this.
Back to Top
Micah View Drop Down
Newbie
Newbie


Joined: 17 November 2003
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote Micah Quote  Post ReplyReply Direct Link To This Post 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

%>

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 17 November 2003 at 9:33pm
Update the permissions on the database to give write access to the IUSER account.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.