Hello,
I can store null values in my SQLServer database integer fields. However, I cannot set an Int32 variable to null in my C# application.
It's a 3-tier application, and I'd prefer to keep the bulk of it non-DB dependant. I'd prefer to use a standard integer type, not SQL types (SQLInt32 etc) as they are not serializable.
What are other developers doing to get around this problem? I'd happily write a little function in the DAL to make my "empty" variables equal to DBNull.value (so I can pass them to my stored procedures), but how should I deal with integers that can be null in the main body of my program? Are you writing your own types because the C# aren't all the useful in the real world?
Thanks
I can store null values in my SQLServer database integer fields. However, I cannot set an Int32 variable to null in my C# application.
It's a 3-tier application, and I'd prefer to keep the bulk of it non-DB dependant. I'd prefer to use a standard integer type, not SQL types (SQLInt32 etc) as they are not serializable.
What are other developers doing to get around this problem? I'd happily write a little function in the DAL to make my "empty" variables equal to DBNull.value (so I can pass them to my stored procedures), but how should I deal with integers that can be null in the main body of my program? Are you writing your own types because the C# aren't all the useful in the real world?
Thanks