Library tutorials & articles
Extracting the Country from the IP Address:- How To?
By Amit Gupta, published on 13 Mar 2004
The Database
There are many services, both Free & Commercial, which provide you the geographic data of the visitors to your website. We will however use the free IP-Country database provided by
http://ip-to-country.webhosting.info. This database is available in the CSV format & can be imported into other databases like MS-Access, MS-SQL, MySQL, etc. Since we will be using ASP & MS-Access, we will thus download this csv database & import it into an MS-Access database.
The MS-Access database containing the records from the downloaded csv database is attached with this tutorial. The full code used in this tutorial is at the end.
So after importing the CSV file into an MS-Access database, we name the database as ip2country & the table as ip2c.
Now, there are 5 columns in our table ip2c, namely, ip_from, ip_to, co_code2, co_code3 & co_name.
Instead of storing IP Address, which are in format xxx.xxx.xxx.xxx, this database has IP number ranges. The ip_from marks the beginning of range & ip_to ends it. The co_code2 column has the 2Digit country code & co_code3 has 3Digit Country Code. The column co_name has the full country name.
Now we will proceed to writing the ASP code.
http://ip-to-country.webhosting.info. This database is available in the CSV format & can be imported into other databases like MS-Access, MS-SQL, MySQL, etc. Since we will be using ASP & MS-Access, we will thus download this csv database & import it into an MS-Access database.
The MS-Access database containing the records from the downloaded csv database is attached with this tutorial. The full code used in this tutorial is at the end.
So after importing the CSV file into an MS-Access database, we name the database as ip2country & the table as ip2c.
Now, there are 5 columns in our table ip2c, namely, ip_from, ip_to, co_code2, co_code3 & co_name.
Instead of storing IP Address, which are in format xxx.xxx.xxx.xxx, this database has IP number ranges. The ip_from marks the beginning of range & ip_to ends it. The co_code2 column has the 2Digit country code & co_code3 has 3Digit Country Code. The column co_name has the full country name.
Now we will proceed to writing the ASP code.
Related articles
Related discussion
-
Binary Studio | software development outsourcing Ukraine
by Soft Industry (5 replies)
-
asp Request.QueryString("dir")
by realmeteo (1 replies)
-
Looking for Senior Web Designer
by lwsmedia (0 replies)
-
Read eMails from Outlook express using ASP
by kumaravelu (1 replies)
-
Help to Call ASP function from onclick event in HTML to pass an array
by vka (0 replies)
Related podcasts
-
Scott Guthrie
Scott catches up with Scott Guthrie in an interview covering Ajax, Asp 2.0, extender controls, CSS adapters and more.
Comments
Leave a comment
Sign in or Join us (it's free).