存储过程 日期可以为空 怎么判断是否空 插入数据日期?急,谢谢。
#region 增
public static bool AddBook(Book model)
{
bool Flage = false;
string procname = "dbo.AddBook";
SqlParameter[] prams ={
new SqlParameter("@UserId",SqlDbType.Int),
new SqlParameter("@ChuBanRiQi",DateTime)};
prams[0].Value = model.userId;
prams[1].Value = model.ChuBanRiQi;
int add = DataBase.RunExecute(procname, prams);
if (add > 0)
{
Flage = true;
}
return Flage;
}
--------------------编程问答-------------------- 有人知道吗? --------------------编程问答-------------------- 存储过程 日期为空 怎么写? --------------------编程问答-------------------- 如果是在插入的语句中参数中写用:System.DBNull.Value;
model.userId = 1;
if(txtChuBanRiQi!=null)
{
model.ChuBanRiQi=Convrt.ToDateTime(txtChuBanRiQi.text);
}
else
{
model.ChuBanRiQi= ?
}
/code]
[code=SQL]
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[AddSaleCar]
(
@userId int,
@ChuBanRiQi datetime,
)
AS
insert into c_sale_car(userId,ChuBanRiQi)
values(@userId,@ChuBanRiQi)
RETURN
在sql语句中,用IsNull判断就行了
ISNULL ( check_expression , replacement_value )
补充:.NET技术 , ASP.NET