Is there any provable reason why I should always specify the SQL data type for SqlCommand paramenters?
+1
A:
The only time I've run into a case when I had to specify a data type was when passing in DBNull. When I wasn't specifying a data type, it defaulted to a Varchar, and ended up crashing because I was trying to set an integer value to Null.
Kibbee
2008-11-29 01:20:26
A:
and you will find that sometimes you will get very strange errors when you have not specified the sql type and size
it is safest - and more self-documenting - to always declare the correct sql type and size
Steven A. Lowe
2008-11-29 02:54:10
Can you give me an example?
Jonathan Allen
2008-11-29 19:24:48
@Grauenwolf: there was a 'wierd SQL error' SO post ~ a week ago caused by not specifying the length of a varchar, but i searched and could not find it. so no, i can't give you a specific example but i can assure you that it does happen. Let me ask you: why would you trust/assume w/out specifying?
Steven A. Lowe
2008-11-30 02:14:05