Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 Cannot UPDATE a Foxpro Database Record (Data Mismatch)

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-10 : 09:14:41
Jorge writes "I am trying to write to the database some decimal numbers, ranging from 1.0 to 10.0. But I am getting an error, let me explain in detail:

When I do a VarType() on the Database Field, I get a value of 5, which is a double.

For example:
Response.Write VarType(rs("field"))
Returns Value "5"

However, even if I try using the same datatypes "x = CDbl(200.5)" and run the update statement. I still receive an error.

But When I type the value directly into the SQL UPDATE Statement, it works fine!

EXAMPLE OF MY CODE BELOW:


THIS STATEMENT BELOW WORKS FINE!
------------------------------------------------------
strSQL2 = "UPDATE Users SET"
strSQL2 = strSQL2 & " votesum = 200 WHERE sn = '" & strSN & "'"
objCmd.CommandText = strSQL2
objCmd.CommandType = 1
objCmd.Execute

HOWEVER THIS STATEMENT GIVES ME A DATA MISMATCH ERROR
------------------------------------------------------
Dim x
x = 200.5 OR EVEN IF I PUT x = CDbl(200.5)
strSQL2 = "UPDATE Users SET"
strSQL2 = strSQL2 & " votesum = '" & x & "' WHERE sn = '" & strSN & "'"
objCmd.CommandText = strSQL2
objCmd.CommandType = 1
objCmd.Execute


PLEASE HELP!!!"
   

- Advertisement -