IP address into MS Access database

This is a discussion on "IP address into MS Access database" within the Classic ASP section. This forum, and the thread "IP address into MS Access database are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 16th, 2007, 09:53
New Member
Join Date: Dec 2005
Age: 42
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
IP address into MS Access database

Hello

I am trying to store visitors' IP addresses into an MS Access database.

I have two fields (visitorID, which is my AutoNumber, and IPAddress which has a text data field and allows zero length values) in a table called sIPAddresses.

I am using the following code:

<%

' Declare variables

Dim sIPAddress
sIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If sIPAddress="" Then sIPAddress = Request.ServerVariables("REMOTE_ADDR")

'Open MS Access database, store form field values

set conn=Server.CreateObject("ADODB.Connection")

conn.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=D:\name\form.mdb;"

set rs = Server.CreateObject("ADODB.recordset")
SQL="INSERT INTO sIPAddresses (IPaddress) VALUES ('" & _
IPaddress & "')"

rs.Open SQL, conn
Set rs=Nothing

' Close the connection

conn.Close
Set conn=Nothing
%>

I do not get an qerror message, but I canot see that the databse is storing any IP addresses.

Can anybody assist, please?

Many thanks.

Quetzal
Reply With Quote

  #2 (permalink)  
Old Jan 19th, 2007, 02:28
New Member
Join Date: Feb 2006
Location: Australia
Age: 37
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: IP address into MS Access database

Try this (untested but is the normal way i do things like this)
Code: Select all
sIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If trim(sIPAddress)="" Then 
  sIPAddress = Request.ServerVariables("REMOTE_ADDR")
End If
HTH
Alex
Reply With Quote
  #3 (permalink)  
Old Jan 19th, 2007, 09:34
New Member
Join Date: Dec 2005
Age: 42
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: IP address into MS Access database

Hello Alex

Many thanks for your reply.

Yes, it worked, thanks, and the IP addresses are now stored in the database.

Thanks for your help.

Quetzal
Reply With Quote
Reply

Tags
ip address

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
using access database ? saadi babar Classic ASP 13 Mar 19th, 2008 09:45
Access Database benjamjon Databases 1 Mar 8th, 2007 20:19
Sending database record ID as a membership number t an email address frinkky PHP Forum 3 Nov 30th, 2006 02:45
display web address with link from database! Monie Classic ASP 3 Aug 29th, 2004 13:39
Access database on the Web redkyna Databases 7 Aug 2nd, 2004 20:25


All times are GMT. The time now is 06:23.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43