views:

456

answers:

1

I have a web service which has a generic function that returns a dataset from results of stored procedures... Some of the stored procedures have optional parameters where the value can be null but not all the time.

Anyhow I am trying to pass in a parameter which has a value of DBNull.Value

and I get this There was an error generating the XML document. back from the web service when doing so

If I leave this parameter out it works fine... but really would like to know why DBNull.Value causes this problem.

+1  A: 

I beleive that's becuase a System.DBNull value is a null in database table but a null field in a procedure effectively equates to the null/nothing keyword. Not a database null value. I'm not sure of the technical differences under the hood.

But in your stored proc you can just default it to null and not send the value as you've already done or i believe if you sent null/nothing it would also work.

Robert