Question

I have problems inserting a null paramater with the AddInParameter method.

cmd.AddInParameter(someString, someValueWhichCanBeNULL)

As soon as the 2nd param is null, it fails. I also Tried DBNull.Value, fails too. Ideas?

The message is: AddInParameter @MyParam with null value or Unsupported Property Type: DBNull

Thanks!

Was it helpful?

Solution

Use the overload of AddInParameter that takes three arguments; you want this:

cmd.AddInParameter(someString, DbType.String, someValueWhichCanBeNULL);

(It can't determine the type of the parameter from the DBNull.Value alone)

Hope that helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top