bri189a Posted February 12, 2006 Posted February 12, 2006 So if DateTime is suppose to be Nullable in 2.0 why do I get this error (nullable value types is suppose to be something support in 2.0 I believe)? Basically I have a form where I'm updating the date, the date can be null in the database if it's not used, meaning I must be able to set the field to null from the front end application. Basically what I'm doing in my DataList is if the text box that represents the Date is blank, I don't set the Update Parameter. I have tried the 'ConvertEmptyStringToNull' property to both true and false, both get the same errors. I hate to have to do a bunch of special if statements looking for DateTime.MinValue - but if I have to do it so be it. But now in my stored procedure I have to look for that value and set the value manually to null in the stored procedure; which is just plain bad. Any help would be appreciated. Quote
bri189a Posted February 12, 2006 Author Posted February 12, 2006 So the answer to this one is that the ObjectDataSource has a propert called ConvertNullToDBNull - you need to set this to false which is kind of non-intuitive - to me at least. What's it saying behind the scenes is that whenever you have a null value for a parameter it's going to being passing DBNull to the underlying business object - in my case a DataSet/TableAdapter. The TableAdapter parameter has the System.Nullable structure (or whatever you want to call it) but apparently DBNull isn't one of those. It's weird, I can't fully explain it yet but this was the work around. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.