jump to navigation

VB.NET NULL Stored Procedure Parameters May 04 2004

Suppose you have a stored procedure that can accept a NULL value. In order to pass a NULL value in VB.NET this is not as simples as “NULL”

The correct thing to do is ‘System.DBNULL.Value’

Here is an example that will work:

=== BEGIN ===

Dim paramInodeParent As New SqlClient.SqlParameter
paramInodeParent = cmd.Parameters.Add (”@inode_parent_inode_id”,SqlDbType.Int, 4)
paramInodeParent.Direction = ParameterDirection.Input
If inode_parent_inode_id > 0 Then
paramInodeParent.Value = inode_parent_inode_id
Else
paramInodeParent.Value = System.DBNull.Value
End If

=== END ===

Comments»

no comments yet - be the first?