473,396 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

data type mismatch error

Hi,

Getting the following error:-
Microsoft JET Database Engine error '80040e07'

Data type mismatch in criteria expression.

The code is as follows, and the last line is the one that produces the
error.

set con = server.createobject("adodb.connection")
con.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE="&
server.mappath("uk.mdb") &""

slocSQL = "SELECT COUNTRY_CODE3 FROM ip_country WHERE " & Dot2LongIP & "
BETWEEN IP_FROM AND IP_TO"
Set RsLoc = con.Execute(slocSQL)

I've searched for the error on aspfaq.com, and the error message apparently
refers to inserting invalid dates. However, the data in Dot2LongIP is a
number, and the fields in the database it's trying to look up are both
columns of numerical data, and the columns are set to be text. I've tried
changing the columns in the database to be numeric, but for some reason it
deletes a lot of records, so that appears not to be an option.

Additional info:-

What I'm trying to do is detect visitors country, and send them to a
different version of the page if they are from the UK. I'm attempting to use
the above with the ip-2-country database that I've converted from .csv to
..mdb. Using this database seems to be a good option IF I can get it to work!
However, if anyone has any suggestions about different ways of achieving
redirect if UK visitor then I'd be happy to hear it. I've looked at various
commercial options, but all are way out of what I can financially justify.

I don't work with asp very often, so I'd be grateful for any advice or
assistance!
Feb 11 '06 #1
5 2210

"David" <da*********@tesco.net> wrote in message
news:Sm*******************@newsfe5-gui.ntli.net...
Hi,

Getting the following error:-
Microsoft JET Database Engine error '80040e07'

Data type mismatch in criteria expression.

The code is as follows, and the last line is the one that produces the
error.

set con = server.createobject("adodb.connection")
con.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE="&
server.mappath("uk.mdb") &""

slocSQL = "SELECT COUNTRY_CODE3 FROM ip_country WHERE " & Dot2LongIP & "
BETWEEN IP_FROM AND IP_TO"
Set RsLoc = con.Execute(slocSQL)

I've searched for the error on aspfaq.com, and the error message
apparently refers to inserting invalid dates. However, the data in
Dot2LongIP is a number, and the fields in the database it's trying to look
up are both columns of numerical data, and the columns are set to be text.

I asume you are trying to compare ip numbers, you would need to treat them
as text, or remove the dots

try Cstr(IP_FROM ) Cstr(IP_TO )


I've tried changing the columns in the database to be numeric, but for some reason it
deletes a lot of records, so that appears not to be an option.

Additional info:-

What I'm trying to do is detect visitors country, and send them to a
different version of the page if they are from the UK. I'm attempting to
use the above with the ip-2-country database that I've converted from .csv
to .mdb. Using this database seems to be a good option IF I can get it to
work! However, if anyone has any suggestions about different ways of
achieving redirect if UK visitor then I'd be happy to hear it. I've looked
at various commercial options, but all are way out of what I can
financially justify.

I don't work with asp very often, so I'd be grateful for any advice or
assistance!

Feb 11 '06 #2
David wrote:
Hi,

Getting the following error:-
Microsoft JET Database Engine error '80040e07'

Data type mismatch in criteria expression.

The code is as follows, and the last line is the one that produces the
error.

set con = server.createobject("adodb.connection")
con.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE="&
server.mappath("uk.mdb") &""

slocSQL = "SELECT COUNTRY_CODE3 FROM ip_country WHERE " & Dot2LongIP
& " BETWEEN IP_FROM AND IP_TO"
Set RsLoc = con.Execute(slocSQL)


Yet another problem caused by the use of dynamic sql ;-)
The ip fields are text, so you need to compare them with a string - you tell
the query engine that you are using a string by surrounding it (delimiting
it) with quotes.
" ... WHERE '" & Dot2LongIP & "' ... "

Here is some more infor:
http://www.google.com/groups?hl=en&l...TNGP12.phx.gbl

However, that's the hard way to do it. The better way is to use parameters.
Why? Because using parameters means you never have to deal with these
delimiter issues again, as well as never again leaving yoursself open to the
risks of sql injection
(http://mvp.unixwiz.net/techtips/sql-injection.html).Try using a parameter
marker, like this:

slocSQL = "SELECT COUNTRY_CODE3 FROM ip_country " & _
"WHERE ? BETWEEN IP_FROM AND IP_TO"
dim cmd
set cmd = createobject("adodb.command")
cmd.commandtype = 1 'adCmdText
cmd.commandtext=slocSQL
set cmd.activeconnection=con
set rs=cmd.execute(,array(Dot2LongIP))

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Feb 11 '06 #3
Bob Barrows [MVP] wrote:
(http://mvp.unixwiz.net/techtips/sql-injection.html).Try using a
parameter


I don't know how that happened ... the link should read

http://mvp.unixwiz.net/techtips/sql-injection.html

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Feb 11 '06 #4

"Slim" <me@here.com> wrote in message
news:en***************@tk2msftngp13.phx.gbl...

"David" <da*********@tesco.net> wrote in message
news:Sm*******************@newsfe5-gui.ntli.net...
Hi,

Getting the following error:-
Microsoft JET Database Engine error '80040e07'

Data type mismatch in criteria expression.

The code is as follows, and the last line is the one that produces the
error.

set con = server.createobject("adodb.connection")
con.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE="&
server.mappath("uk.mdb") &""

slocSQL = "SELECT COUNTRY_CODE3 FROM ip_country WHERE " & Dot2LongIP & "
BETWEEN IP_FROM AND IP_TO"
Set RsLoc = con.Execute(slocSQL)

I've searched for the error on aspfaq.com, and the error message
apparently refers to inserting invalid dates. However, the data in
Dot2LongIP is a number, and the fields in the database it's trying to
look up are both columns of numerical data, and the columns are set to be
text.

I asume you are trying to compare ip numbers, you would need to treat them
as text, or remove the dots

try Cstr(IP_FROM ) Cstr(IP_TO )


Sorry i missled you, I hav shown you how to convert text to be used in
VBscript, not SQL

Bob has shown you the correct way in the same thread

I've tried
changing the columns in the database to be numeric, but for some reason
it deletes a lot of records, so that appears not to be an option.

Additional info:-

What I'm trying to do is detect visitors country, and send them to a
different version of the page if they are from the UK. I'm attempting to
use the above with the ip-2-country database that I've converted from
.csv to .mdb. Using this database seems to be a good option IF I can get
it to work! However, if anyone has any suggestions about different ways
of achieving redirect if UK visitor then I'd be happy to hear it. I've
looked at various commercial options, but all are way out of what I can
financially justify.

I don't work with asp very often, so I'd be grateful for any advice or
assistance!


Feb 11 '06 #5
Thanks for the reply - ' " & is about the only combination of operators I
didn't try!!!
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:eG****************@TK2MSFTNGP15.phx.gbl...
David wrote:
Hi,

Getting the following error:-
Microsoft JET Database Engine error '80040e07'

Data type mismatch in criteria expression.

The code is as follows, and the last line is the one that produces the
error.

set con = server.createobject("adodb.connection")
con.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE="&
server.mappath("uk.mdb") &""

slocSQL = "SELECT COUNTRY_CODE3 FROM ip_country WHERE " & Dot2LongIP
& " BETWEEN IP_FROM AND IP_TO"
Set RsLoc = con.Execute(slocSQL)


Yet another problem caused by the use of dynamic sql ;-)
The ip fields are text, so you need to compare them with a string - you
tell the query engine that you are using a string by surrounding it
(delimiting it) with quotes.
" ... WHERE '" & Dot2LongIP & "' ... "

Here is some more infor:
http://www.google.com/groups?hl=en&l...TNGP12.phx.gbl

However, that's the hard way to do it. The better way is to use
parameters. Why? Because using parameters means you never have to deal
with these delimiter issues again, as well as never again leaving
yoursself open to the risks of sql injection
(http://mvp.unixwiz.net/techtips/sql-injection.html).Try using a parameter
marker, like this:

slocSQL = "SELECT COUNTRY_CODE3 FROM ip_country " & _
"WHERE ? BETWEEN IP_FROM AND IP_TO"
dim cmd
set cmd = createobject("adodb.command")
cmd.commandtype = 1 'adCmdText
cmd.commandtext=slocSQL
set cmd.activeconnection=con
set rs=cmd.execute(,array(Dot2LongIP))

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Feb 11 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: LJgrnl | last post by:
I've got a type mismatch error that's driving me nutty. Variable blnNoData has the initial value False. If a recordset comes back empty (both .EOF and ..BOF are true) then blnNoData is set to...
1
by: deko | last post by:
Okay, so I figured out how to pull Outlook Appointments into an Access Table (see below). But the data comes in the wrong Data Type - how do I convert it from Text to Long Integer? For...
2
by: Chicken Kebab Abdullah | last post by:
Does anyone know why I get the error 3464 Data type mismatch from the following code. I have a form with a combo(to choose a consumable) and 2 list boxes on it. list on left is all printers...
0
by: news.paradise.net.nz | last post by:
I have been developing access databases for over 5 years. I have a large database and I have struck this problem with it before but can find nothing in help or online. Access 2000 I have a query...
1
by: ArcadeJr | last post by:
Good morning all! I have been getting a Run-time Error message #3464 - Data Type mismatch in criteria expression. While trying to run a query. I have a database where the field Asset_Number...
3
by: Jake | last post by:
I am currently trying to create my own Point Of Sale software for my retail store. I wrote the program with the UPC field as Long integer. When I started to add the products by UPC code, I got a...
1
by: amitbadgi | last post by:
I am getting the following error while converting an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Data type mismatch in criteria expression. ...
2
by: psychomad | last post by:
Please, can someone help me out to solve this error, i've been searching throughout my codes and yet i didnt succeed in finding the error!!!! The Error is: Server Error in '/' Application....
15
by: sara | last post by:
I have a Memo field in a table to hold notes from a conversation a social worker has had with a client (this is for a non-profit). If the user needs to update the memo field, I need to find the...
19
by: Lysander | last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.