Null and Stored Procedure

  • Thread starter Thread starter arne
  • Start date Start date
A

arne

How do I pass a null to a stored procedure from VB.Net.
I have tried to pass nothing but that throws an exception.
Here is my parameter
command.Parameters.Add(New SqlParameter("@DLExpiration",
SqlDbType.SmallDateTime, 4, ParameterDirection.Input,
False, 16, 0, _
"DLExpiration", DataRowVersion.Proposed,
DB.getDate(Me.DLExpirationDate.Text)))
 
Try the following:

command.Parameters.Add(New SqlParameter("@DLExpiration",
SqlDbType.SmallDateTime, 4, ParameterDirection.Input,
False, 16, 0, _
"DLExpiration", DataRowVersion.Proposed,
DBNull.Value))
 
In the SP definition

CREATE PROCEDURE myProc
(inParm1 varchar(20) = 'some default')
AS ...

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Back
Top