Friday, February 24, 2012

how to store an "" value in my database instead of null

I have a problem I 'get stuck on it. i hope someone can help me.

I have a SQLServer table with an ID-field with a primary key and identity on it, and a couple of other fields with defaultvalue "" and NOT nullable

When i like to update an record in an formview of ASP 2.0 and fill in all fields everything is updated and everything goes fine

but

when I leave one field blank then I get the message 'can not enter null value in column X'

even when I place in the Updateparameter in my code

<asp:Parameter Name="Name" DefaultValue="" /> ASP tries to update an Null value

when i place an space as default value like

<asp:Parameter Name="Name" DefaultValue=" " />

everything goes fine exept there is an space in my database.

How can I update my record, and leave some textboxes emtpy AND where my fields are NOT nullable

I'm getting desparate of this.

make my fields nullable is not an option because this is a 'customerswish'

Please help

There is another property of the parameter, something like nullempty, or emptynull, nullifyemtpy. Because all form variables are encoded as strings, you can't really represent the null value, and in most cases where you are doing form entry from the web, leaving a field blank should enter a null value (As if the value is unknown/unspecified), so the default for this property of the parameter is ON.|||

Thanks a lot, that's the one.

Shame on me, why haven't I see this setting.

is this new in 2005 (I've previously working with Beta 2) and this occur in my 2005 projects

Thanks

No comments:

Post a Comment