Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DBNull.value will not update field in DB why?????

Status
Not open for further replies.

damann

Technical User
Jul 19, 2000
114
US
Hello all,

I'm passing DBNull.value as a parameter in my store procedure, yet it's not updating the field in the DB (SQL Server 2000). Here's the line of code that does it here:

updateSqlCommand.Parameters["@dDate"].Value = DBNull.Value

Is this because it's a date field? If it is, then how do I pass a null value as a parameter to update a date field?


Thanks,
Damann
 
I think you could use:

Code:
System.Convert.DBNull

Try it and let me know as I'm not sure myself!

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Actually, thinking about it I'm not so sure that this will work!

I think that, as it is a date field, it may be that you have to create a storedprocedure to do the update and in the stored procedure check for a value (i.e. you pass it "1/01/1900") and if it equals that value then you set it to null actually in the sp.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Also check that the date field in the SQL Table is set to allow Nulls.

Sweep
...if it works dont mess with it
 
I got it fixed now... It was being reset in the SP to the previous value, that's why...


Thanks a bunch for all your help though!!!!



Regards,
Damann
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top