I have this code:
var SQL ="SP_PROC";
SqlCommand cmd = new SqlCommand(SQL, connection)
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@dcd_first_name", name);
cmd ExecuteNonQuery();
Why does AddWithValue
when is dcd_first_name
SQL Server Profile gives me default? And when stored procedure executes, it crashes the execution.
Profile gives me: EXEC SP_PROC default
I thought when I pass a null in parameter, in this case name automatically AddWithValue
convert to DBNull.Value
. I have to specify it.
Is it the best method to use AddWithValue
the parameter?