Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error converting data type varchar to numeric.

Status
Not open for further replies.

FiberGhost

Instructor
Feb 6, 2002
3
US
I have a ASP webform that reads data from a Microsoft SQL 7 database and displays it on a webform. You can then edit the data and resubmit it.

One of the fields is Hours (time) spent on the project. The data type in SQL is numeric. After reading the data in and posting it to the form, when the user updates the hours and hits submit I got the following error.

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC SQL Server Driver][SQL Server]Error converting data type varchar to numeric.
/so/SOLookup.asp, line 23

The data type is numeric. I can not figure it out. I change the datatype to int and then same thing occurs but it says...

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC SQL Server Driver][SQL Server]Error converting data type varchar '5.5' to int.
/so/SOLookup.asp, line 23

Any ideas?
 
in ur insert query i think u would have used something like this:
insert into table value('5.5')

change that to:
insert into table value(5.5)

for integres and number do not use the single qt.



Known is handfull, Unknown is worldfull
 
It may be better to convert the data type in your page arther than forcing the database to do it for you:
Code:
sqlStr = "insert into table(fieldname) values(" & cDbl(myNumber) & ")"

or if your using the recordset

rs("fieldname") = cDbl(myNumber)

I use cDbl only as an example, if it is an interger field type than you would probably want to use cInt.

-Tarwn

01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101
29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
Thank you very much. I did not even realize I had '' around my variable in my insert string. I removed that and it works great.

I used the cDble after I validated it as a number for data checking.

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top