Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

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 ASP Free Forums Sponsor:
  #1  
Old September 20th, 2004, 12:15 PM
VJVE VJVE is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 4 VJVE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation SQL Server 2000 VBScript Type Mismatch Error - Help Please

Hi,
I am retrieving Stock price from SQL Server table and assigning to a variable. When I try to perform any numeric related operation it is giving me type mismatch error. These are the lines of code I have

stkPrice = 0
QRYstr = "EXEC sp_DS_selectBySymbolIDandDate " & "'" & SymbolID & "','" & ProcDate & "'"
QRYrset.Open QRYstr,dbConn,0,1
If Not QRYrset.EOF Then
stkPrice = QRYrset("DS_CLOSE")
End If
QRYrset.Close

This is the exact simplified version of the code. All variables are declared properly. This DS_CLOSE column is defines as Numeric(6,2) in SQL Server 2000. This QRYrset has one record after execution and this DS_CLOSE has value of 60.62 and stlPrice has same value of 60.62.

Error comes when I try to do any Arithmatic operation on field stkPrice.
For example If stkPrice > 0 Then -------------- This line fails
If stkPrice > "0" Then --------- This line works.
I couldn't use stkPrice on any Division operation etc .. I am getting type mismatch error.

My question is?
1) What is wrong in the code?
2) Do I have to define the field as Money/SmallMoney in the SQL Server if I am going to perform Arithmatic operations using values in the field by retrieving through recordsets?
Please give me a solution..

Thanks,
Vijay

Reply With Quote
  #2  
Old September 24th, 2004, 01:57 AM
Yeruhn's Avatar
Yeruhn Yeruhn is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Netherlands
Posts: 428 Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 16 h 35 m 27 sec
Reputation Power: 10
I guess this will work:
stkPrice = cdbl(QRYrset("DS_CLOSE"))

I hate typeless programming languages...

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > SQL Server 2000 VBScript Type Mismatch Error - Help Please


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


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





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