Welcome! and rules
Joel on Software
Why can't you cast DBNull to string?
It's been really bugging me. It would help if there were a good reason.
I'd imagine it's because null represents the absence of any value so you can't cast nothing to something.
Probably because an empty string and Null are different values in SQL Server. If you do:
"Why can't you cast DBNull to string?" - because it isn't a string. But it does have a ToString() method that returns an empty string.
>"Why can't you cast DBNull to string?" - because it isn't a string.
Sorry, but "cast" does not mean "convert." ... I'm not being pedantic - you've got your terminology wrong. It'll really help to understand the difference.
Just write a series of DB value interface functions, that return the type you want if it is a null.
I am stuck. I have a datagrid with a dropdown. I have coded it to work with Edit - Delete. But when I try to do an Add - I must throw a Clone of the DataSet (DataTable) back at the ASP DropDown and it throws an error since the DataTextField and DataValueField are strings and can not accept DbNull.
Fog Creek Home