Update query that won't take DBNull

  • Thread starter Thread starter michael
  • Start date Start date
M

michael

I have a stored procedure that I let the wizard create a function in the
QueriesTableAdapter class. Some of the parameters to the stored procedure
clearly allow for nulls (AllowDBNull) but somehow the wizard refused to add
the Global.System.Nullable(Of String) to the generated function's parameter
list. Now I can't use the function if the parameter is DBNull.Value. Can I go
and edit the Designer.vb manually or is there a way to cause the wizard to
recognize that the function should make the parameter Nullable(Of Type)?
 
OK. I must repent for being a bozo. First, when the Type is String, you can't
place it in Nullable(Of Type). This is for Value Types only. If you need to
make the value null, use Nothing.

Now, had I been using an actual SQLParameter, I could have assigned the
..value to DBNull.value
 
Michael,

DBNull.Value is a value type
Nullable(Of Type) has a value type that is not the DBNull.Value

If you want to set a value type Null in SQL Server, you have to tell that
the value you are delivering is a Data Base Null. Value (type).

Cor
 
Back
Top