Hi,
I'm using VS 2005. I can't figure out how to pass a null value as a parameter to a stored procedure.
Ex:
dim da as new DataTableAdapter
da.GetData("Pass a null value here instead of a string")
How can I accomplish this? I've tried passing dbnull.value, dbnull.value.tostring...but I can't get anything to work.
Thanks.
How to pass a null value to a stored procedure in .NET?
-
- Posts: 20
- Joined: Thu 31 Aug 2006 18:19
I can't see any problems in passing DBNull.Value.ToString(). Take a look at the following code:
where test_tinybooleanTableAdapter was created using our DataSet Wizard.
Code: Select all
WindowsApplication1.DataSet1TableAdapters.test_tinybooleanTableAdapter ta = new WindowsApplication1.DataSet1TableAdapters.test_tinybooleanTableAdapter();
DataTable dt = (DataTable)ta.GetData(DBNull.Value.ToString());
-
- Posts: 20
- Joined: Thu 31 Aug 2006 18:19
Hi,
Thanks for the response. It does work when I pass DBNull.Value.ToString as a parameter to a typed dataset, but only when the column is defined as a string.
If I pass it to a column that is of a different type, such as tinyint or int, then I get this error:
Input string was not in a correct format.
Thanks for the response. It does work when I pass DBNull.Value.ToString as a parameter to a typed dataset, but only when the column is defined as a string.
If I pass it to a column that is of a different type, such as tinyint or int, then I get this error:
Input string was not in a correct format.
-
- Posts: 20
- Joined: Thu 31 Aug 2006 18:19