我的存儲過程是這樣的:如何將空值發送到存儲過程?
CREATE PROCEDURE [dbo].[insertCompList_Employee]
@Course_ID int,
@Employee_ID int,
@Project_ID int = NULL,
@LastUpdateDate datetime = NULL,
@LastUpdateBy int = NULL
AS
BEGIN
SET NOCOUNT ON
INSERT INTO db_Competency_List(Course_ID, Employee_ID, Project_ID, LastUpdateDate, LastUpdateBy)
VALUES (@Course_ID, @Employee_ID, @Project_ID, @LastUpdateDate, @LastUpdateBy)
END
我的asp.net VB代碼背後如下:
dc2.insertCompList_Employee(
rdl_CompList_Course.SelectedValue,
RadListBox_CompList_Select.Items(i).Value.ToString,
"0",
DateTime.Now,
HttpContext.Current.Session("UserID")
)
我想插入一個null
值的Project_ID
代替0
我已嘗試NULL
,'NULL'
但它返回錯誤。
您是否嘗試過通過空不帶引號或通過DBNull.Value – Arun
是的,我曾試圖DBNull.Value , 空值, 」」。但它不起作用 –