| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
I guess this will work:
stkPrice = cdbl(QRYrset("DS_CLOSE")) I hate typeless programming languages... |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > SQL Server 2000 VBScript Type Mismatch Error - Help Please |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|