ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old May 28th, 2003, 11:41 AM
jmiller jmiller is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 35 jmiller User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 30 sec
Reputation Power: 6
string to number conversion trouble

I'm passing variables via the URL to an ASP page and then using same to query an Access db and I keep getting the "data type mismatch in criteria expression" error. The variable is a milepost reading up to the thousandths. In the Access DB the data shows as field size = double and decimals as auto. I've tried using both the CDbl and the CDec functions to convert my variables to the correct data type prior to doing the SQL query. I had the same problem with two other variables but converted those to text in the db to fix those but don't want to do that with this one. Here is what I have:

milepostS = Request.QueryString("MILEPOST")
roadNumberS = Request.QueryString("ROAD_NUMBE")
sequenceS = Request.QueryString("SEQUENCE")
milepost = CDbl(milepostS)

Conn.Open "CRIS_WEB"

SQL = "SELECT * FROM culverts WHERE ROAD_NUMBE = '" & roadNumberS & "' AND MILEPOST = '" & milepost & "' AND SEQUENCE= '" & sequenceS & "'"

Set RS = Conn.execute(SQL)

How should I convert milepostS to the proper type?

Thanks.
__________________
Jeff

Reply With Quote
  #2  
Old May 28th, 2003, 03:18 PM
defjamninja defjamninja is offline
Overly white
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Fresno, CA
Posts: 83 defjamninja User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Re: string to number conversion trouble

The problem is not the variables but your SQL. When looking up numbers you don't use quotes around them. See if this solves the problem.

Code:
SQL = "SELECT * FROM culverts WHERE ROAD_NUMBE = " &
roadNumberS & " AND MILEPOST = " & milepost & " AND
SEQUENCE= '" & sequenceS & "'"

Reply With Quote
  #3  
Old May 30th, 2003, 04:17 AM
peter_melb peter_melb is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: Australia
Posts: 3 peter_melb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
sounds like that mite be it .. only text matching in the query string will have quotes in the SQL statement.
But sometimes even with the SQL statement being correct there mite still be a mismatch problem. Some reasons can be, you are parsing a Number (&milespost) but the Field in the database is of Text type so the SQL statement cant match the number in the Database.. or Vice Versa.

Check the field type in your database and ensure it is in Number Format.

To format the number of the variable parsed from your page. You can try : Assuming VbScript :-

milepost = FormatNumber(milepostS)


However i would first try the SQL given above but do note that all of the statement should be in single line. (just in case u copied and pasted )

for multiple line SQL (taking the above SQL statement again) may look something like :

SQL = "SELECT * FROM culverts WHERE ROAD_NUMBE =" _
& roadNumberS & " AND MILEPOST = " & milepost & " AND _
SEQUENCE= '" & sequenceS & "'"

Hope i have helped

cheers
Peter Pavlidis

Reply With Quote
  #4  
Old May 30th, 2003, 03:27 PM
jmiller jmiller is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 35 jmiller User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 30 sec
Reputation Power: 6
SQL was bad

Thanks both of you for your replies. It was the SQL statement error that defjamninja pointed out. Egad....

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > string to number conversion trouble


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway