L
Larry
In my application I use a field of SQL type bit as a kind of tri-state
indicater; 0, 1, and null. When I insert the record into the database using
a stored procedure I set all the parameters and preform an executeNonQuery.
My problem is that I want to be able to set this one parameter under a given
condition to null initially but I can not find a way to add the parameter
and have the insert work under ADO.NET
here's what I'm trying (although I know it's not working):
Dim spcmd As SqlClient.SqlCommand
spcmd = New SqlClient.SqlCommand("spInsertUserActivity2", Me.SqlConnection2)
spcmd.CommandType = CommandType.StoredProcedure
Dim param As SqlClient.SqlParameter
' set up the parameter values.....
If Me.ddAddAssign2.SelectedItem.Text = owner Then
param = spcmd.Parameters.Add("@accepted", 1)
Else
param = spcmd.Parameters.Add("@accepted", Nothing) ' <<< this is where I
wanted to set the value to DBNULL
End If
' try to do the insert .....
Me.SqlConnection2.Open()
spcmd.ExecuteNonQuery()
Me.SqlConnection2.Close()
This should be an easy answer I would think. but I haven't found a reference
as to what this constant is called.
Is there one, and if so what is it called?
-Larry
indicater; 0, 1, and null. When I insert the record into the database using
a stored procedure I set all the parameters and preform an executeNonQuery.
My problem is that I want to be able to set this one parameter under a given
condition to null initially but I can not find a way to add the parameter
and have the insert work under ADO.NET
here's what I'm trying (although I know it's not working):
Dim spcmd As SqlClient.SqlCommand
spcmd = New SqlClient.SqlCommand("spInsertUserActivity2", Me.SqlConnection2)
spcmd.CommandType = CommandType.StoredProcedure
Dim param As SqlClient.SqlParameter
' set up the parameter values.....
If Me.ddAddAssign2.SelectedItem.Text = owner Then
param = spcmd.Parameters.Add("@accepted", 1)
Else
param = spcmd.Parameters.Add("@accepted", Nothing) ' <<< this is where I
wanted to set the value to DBNULL
End If
' try to do the insert .....
Me.SqlConnection2.Open()
spcmd.ExecuteNonQuery()
Me.SqlConnection2.Close()
This should be an easy answer I would think. but I haven't found a reference
as to what this constant is called.
Is there one, and if so what is it called?
-Larry