I have a table like this
CREATE TABLE [dbo].[tblVolunteers]
(
[VolID] [int] IDENTITY(1,1) NOT NULL,
[VolFName] [varchar](20) NULL,
[DLExpiration] [smalldatetime] NULL,
CONSTRAINT [PK_tblVolunteers] PRIMARY KEY CLUSTERED
([VolID] ASC),
CONSTRAINT [uniqueUserID] UNIQUE NONCLUSTERED ([UserID] ASC)
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
And I have a stored procedure to update data on this table
ALTER PROCEDURE [dbo].[volUpdate]
@StaffID INT,
@ModifiedBy VARCHAR(100),
@NickName VARCHAR(20),
@FirstName VARCHAR(20),
@DLExpiration SMALLDATETIME
AS
UPDATE tblVolunteers
SET
VolNickName = @NickName,
VolFName = @FirstName,
DLExpiration = @DLExpiration
WHERE
VolID = @StaffID
In some cases I don't have a valid DLExpiration to update at that time I want to pass null value to table. And I am doing it like this
new SqlParameter("@DLExpiration", null)
But still it throws an error
Procedure or function 'volUpdate' expects parameter '@DLExpiration', which was not supplied.
Can anyone point out What I am doing wrong here?
SqlParameter.DBNull.Valueinstead ofNULL?