I have a table that contains a nvarchar column that allows nulls.
I have a method in VB.NET that has a optional description variable that is set to Nothing
Public Shared Sub InsertDescription(Optional ByVal Description As String = Nothing)
{
//Insert Description Procedure Call
}
If I call this method like:
InsertDescription();
It fails saying that the procedure was expecting the @Description, but was not provided. The only way I have found to remedy this is to set the default value to “” or to not make it optional and just pass in “”, but I don’t want to insert an “” string into the database tables description column, I want to pass in null by default.
Try using the DbNull.Value
—
Doesn’t this work?
If not, could you post some more relevant code?