Groups | Blog | Home
all groups > dotnet ado.net > march 2008 >

dotnet ado.net : Update query that won't take DBNull


michael
3/25/2008 1:21:03 PM
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)?




--
michael
3/25/2008 2:12:00 PM
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


[quoted text, click to view]
Cor Ligthert[MVP]
3/26/2008 6:12:46 AM
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

"michael" <michael@discussions.microsoft.com> schreef in bericht
news:C86A884E-A51A-4421-95A9-472835171C6C@microsoft.com...
[quoted text, click to view]
AddThis Social Bookmark Button