How to detect Users's IP and then redirect to URL based on IP

Hi there, I need help to put this together. I want to create a basic web page that I will direct our clients to. When they get there they get a basic "You are being Redirected" and in the background I am retrieving their IP address and checking it again either a DB or file and then based on the result I am redirecting them to a SQL Report using that result as a parameter.

Now I am a complete novice to web development but have done some VB and some SQL so if some body could guide me I could probably get there.

How do I do this - I am sure it is a easy as for a web developer out there.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Daniel WilsonCommented:
        Dim strClientIP As String
 strClientIP = Request.UserHostAddress()
mickinoz2005Author Commented:
Thanks for that but what about the query part to the SQL DB or text file.

Any ideas on that.


Daniel WilsonCommented:
dim cmd as SqlCommand = new SqlCommand(new SqlConnection (MyConnStr), "Select RedirectPage from Redirects Where IP = @IP")
dim P as SqlParameter = new SqlParameter("@IP", SqlDBType.nvarchar)
P.Value = strClientIP
cmd.Parameters.Add (P)

dim dr as DataReader = cmd.ExecuteReader
if then
end if

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mickinoz2005Author Commented:
Hi there,

When I add this code to visual studio I get SQLCommand is not defined, same with datareader.

Can you assist with this please.


mickinoz2005Author Commented:
As a complete novice the solution left a lot for me to still resolve which put me really back where I started. The IP part was complete and worked perfectly for not the DB part.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.