Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with integer conversion
Message
 
 
To
12/09/2013 11:32:40
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 6.5 and older
Application:
Web
Miscellaneous
Thread ID:
01582916
Message ID:
01583026
Views:
34
>>
>>The original problem is because he used AddWithValue and the parameter was send as varchar. If he would use Add and exact type, this would not happen.
>>
>>BTW, this works
>>
>>SELECT CAST( 123.45 AS INT)
>
>Well there you go. It occurred to me last night that perhaps the original code would work if I did this:
>
>oCommand.Parameters.AddWithValue("@AmendmentNumber", Val(Amendments_DDL.SelectedValue))
>
>And sure enough it does.
>Thanks to all.

I don't recommend to use AddWithValue as I already said. AddWithValue is a quick way and it often leads to troubles. I suggest to always be explicit and use Add syntax and exact type instead. It also helps to document and requires more strict programming.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform