c# - SQL Server -> .Net int conversion -
i had line of code in winforms app (target platform x86) made contained this...
if (dtmax.rows[0][0] != system.dbnull.value) iprevmax = (int64)(dtmax.rows[0][0]);
i know dtmax.rows[0][0] max
of column in given table in sql server. datatype of column int
.
now - line of code @ point threw exception. don't know exception on holiday , nobody took note!! angry face.
however line changed to....
if (dtmax.rows[0][0] != system.dbnull.value) iprevmax = convert.toint64(dtmax.rows[0][0]);
...and works.
i understand few things...
.net equivalent of sqlserver
int
int32
- should have been unboxing that.convert
"safer" unboxing
but don't understand why line of code work , @ point fail unbox? possible reasons - in spite of annoyingly not knowing actual exception...
Comments
Post a Comment