I want to store a C#.NET ulong
into a T-SQL database. I don't see any provisions for doing this, as the SQL bigint
has the same Min/Max values as a normal long
.
Is there any way I can do this? Or is catching an OverflowException
my only hope?
This should answer your question:
You would use BigInt, you just have to be careful in how you convert the signed type back into an unsigned type in C#
// This has not been tested
unchecked
{
myUlong = myDataReader.GetInt64(...);
}
...
The other possibility is to use VarBinary with a length of 8, then convert the bytes to a ulong in C#