delphi 使用sql存储过程问题
表createtablebiaodan(wordchar(3),orderdatechar(8),numberint,primarykey(word,orderdate,...
表
create table biaodan
(word char(3),
orderdate char(8),
number int,
primary key(word,orderdate,number)
)
存储过程
create proc danhao @p_word char(3),@p_orderdate char(8),@p_number int output,@p_newnum int output
as
set @p_number=1
set @p_newnum=@p_number
if exists (select word,orderdate,number from biaodan where word=@p_word and orderdate=@p_orderdate and number=@p_newnum)
begin
set @p_newnum=(select max(number)from biaodan where word=@p_word and orderdate=@p_orderdate)+1
insert into biaodan(word,orderdate,number)
values(@p_word,@p_orderdate,@p_newnum)
end
else
begin
insert into biaodan(word,orderdate,number)
values(@p_word,@p_orderdate,@p_newnum)
end
delphi中代码
word:='OUT';
orderdate:=formatdatetime('yyyymmdd',now);
datasource1.DataSet:=adostoredproc1;
adostoredproc1.Close;
adostoredproc1.Open;
adostoredproc1.ProcedureName:='danhao;1';
adostoredproc1.Parameters.Refresh;
adostoredproc1.Parameters[1].Value:=word;
adostoredproc1.Parameters[2].Value:=orderdate;
adostoredproc1.Parameters[3].Value:='';
adostoredproc1.Parameters[4].Value:='';
为什么总是提示ordedate为null无法插入???
无论adostoredproc1.Parameters[2].Value:=什么它都提示无法插入空值 展开
create table biaodan
(word char(3),
orderdate char(8),
number int,
primary key(word,orderdate,number)
)
存储过程
create proc danhao @p_word char(3),@p_orderdate char(8),@p_number int output,@p_newnum int output
as
set @p_number=1
set @p_newnum=@p_number
if exists (select word,orderdate,number from biaodan where word=@p_word and orderdate=@p_orderdate and number=@p_newnum)
begin
set @p_newnum=(select max(number)from biaodan where word=@p_word and orderdate=@p_orderdate)+1
insert into biaodan(word,orderdate,number)
values(@p_word,@p_orderdate,@p_newnum)
end
else
begin
insert into biaodan(word,orderdate,number)
values(@p_word,@p_orderdate,@p_newnum)
end
delphi中代码
word:='OUT';
orderdate:=formatdatetime('yyyymmdd',now);
datasource1.DataSet:=adostoredproc1;
adostoredproc1.Close;
adostoredproc1.Open;
adostoredproc1.ProcedureName:='danhao;1';
adostoredproc1.Parameters.Refresh;
adostoredproc1.Parameters[1].Value:=word;
adostoredproc1.Parameters[2].Value:=orderdate;
adostoredproc1.Parameters[3].Value:='';
adostoredproc1.Parameters[4].Value:='';
为什么总是提示ordedate为null无法插入???
无论adostoredproc1.Parameters[2].Value:=什么它都提示无法插入空值 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询