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 Chriss Miller 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.

aspnetuser

Technical User
Sep 9, 2004
273
US
I get the following error message when trying to check a check box that will update a sql field type INT.

Error converting data type varchar to numeric.


web form
hours check box


hours is set to numeric. chekc box is set to int.

it only fails when i try to check a check box and hit submit

it works if both types are set to int

but i need hours as a numeric.

any ideas on how to fix this?

 
cInt where you insert it into the DB should fix it.

___________________________________________________________________

onpnt.com
SELECT * FROM programmers WHERE clue > 0
(0 row(s) affected) -->faq333-3811

 
sql = "update qryEnterHours set Hours = '" & hours & "' where Username = '" & Username & "' and PayDates = '" & PayDates & "'"
set rs = DbConn.Execute(sql)
set rs = nothing

he is where it fails? how do i fix it with cint?
 
take off the single quotes
Code:
sql = "update qryEnterHours set Hours = " & hours & " where Username = '" & Username & "' and PayDates = '" & PayDates & "'"
 
I took them off and get :
Incorrect syntax near the keyword 'where'.
 
Try

Development practices when using SQL/Interfaces
faq333-4896

___________________________________________________________________

onpnt.com
SELECT * FROM programmers WHERE clue > 0
(0 row(s) affected) -->faq333-3811

 
onpnt

It was working fine until I changed the hours data type to numeric and the check box fields stayed int

is their anything else you could help me with?

 
The single quotes need to come out of the hours part, but stay in the username part. You use single quotes in SQL to denote strings: username is almost undoubtedly a string, while hours is not.

Also, you might try the asp.net forum, forum855 I believe.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top