Forum Moderators: open

Message Too Old, No Replies

ASP Country Redirect

         

flyerguy

9:37 pm on May 3, 2005 (gmt 0)

10+ Year Member



I tried the code in this thread: [webmasterworld.com...]

Only change I made was using it with an Access DB instead of SQL.

I am getting the following error:

ADODB.Field error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/ads.asp, line 12

This is the code, anyone have an idea? :

<!--#include file="ipaddressconvert.asp" -->
<%
dbPath = "C:\#*$!\geo.mdb"
DSNString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&dbPath

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open DSNString

slocSQL = "SELECT country_CODE3 FROM ip_country WHERE ' & Dot2LongIP & ' BETWEEN IP_FROM AND IP_TO"

Set RsLoc = Conn.Execute(slocSQL)
check_country = Trim((RsLoc.Fields("country_CODE3").value))
IF RsLoc.EOF THEN
%>
<!--#include file="ads/1.htm" -->
<%
ELSE
IF check_country = "USA" OR "CAN" THEN
%>
<!--#include file="ads/2.htm" -->
<%
ELSE
%>
<!--#include file="ads/1.htm" -->
<%
END IF
END IF
%>

Philly

9:45 pm on May 3, 2005 (gmt 0)

10+ Year Member



you have ti declare the database like:

Dim ConnectString, Connection
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../../path to database.mdb")
Set Connection = Server.CreateObject("ADODB.Connection")
Connection.Open ConnectString

flyerguy

11:09 am on May 4, 2005 (gmt 0)

10+ Year Member



Afraid that didn't solve the issue. I thought you'd get a more general error if the db connection was the issue.

There are 5 columns in the DB: IP_FROM, IP_TO, COUNTRY_CODE2, COUNTRY_CODE3, COUNTRY_NAME.

IP_FROM and IP_TO are numbers. Should these columns be defined in Access as numbers or something other than text for the SQL 'BETWEEN' to function properly?

Philly

2:09 pm on May 4, 2005 (gmt 0)

10+ Year Member



Read this,
[rcsa.com.au...]

and try this...
slocSQL = "SELECT country_CODE3 FROM ip_country WHERE '" & Dot2LongIP & "' BETWEEN IP_FROM AND IP_TO"

Note the quotes around the variable Dot2LongIP. Leave no spaces between quotes. Spread out it would look like this...
' " & Dot2LongIP & " '

Just copy and paste the line.

using 'text' should not be an issue

mrMister

11:33 am on May 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../../path to database.mdb")

Whooooa!

Never, ever put your database below the WebRoot. That's a security disaster waiting to happen!

flyerguy

12:16 pm on May 5, 2005 (gmt 0)

10+ Year Member



Ok, here's phase 2 of this script: user connection speed detection.

I have an ad for a dialup internet service that I do not want to display to people who are already on cable modem/ADSL or higher.

Is there a simple detection routine where I can shoo all the high-speed types away?

Yes I know about Browserhawk but it seems like overkill and it is also seems to be in .NET only. I'm looking for a simple Vbscript..

mrMister

12:23 pm on May 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You want to have two server side scripts that are embedded in your document in some way (either as images or javascript or css)

You want one to be linked at the top of your page and one at the bottom.

I'd recommend javascript for the first embed because it's the easiest in VBScript. you don't have to output and data, you just have to makie sure that the mime type of your scripts is set to "text/javascript"

Store the current time in miliseconds in the Session variable.

As your second script, present it as an ebedded image <img src="speeddetect2.asp">

In that second script you want to subtract the time in the session variable from the current time in milliseconds. If it is below your speed threshold amount (do some speed tests with a modem and with a DSL line to get an idea), then Response.redirect to your graphical advertsement. If it's above the threshold then response.redirect to another image.