大家好
我现在学习存储过程的使用,点击按钮存数据。出现问题:adostoredproc1:parameters '@name'not found
建立了一个简单的表tb_test 字段有:name, sex 两个,均为char(10),
建立存储过程mystoredproc
create proc myprocedproc
@name char(10)
@sex char(10)
as
begin
insert into tb_test (name,sex)values(@name,@sex);
end;
检查语法没错
打开delphi新建工程。通过adoconnection 与数据库建立连接。添加adostoredproc1 procname 指定为 mystoredproc.
点击按钮事件中
with adostoredproc1 do
begin
parameters.parambyname('@name').value:='xiaowang';
parameters.parambyname('@sex').value:='nan';
execproc;
end;
运行出错:adostoredproc1:parameters '@name'not found
我现在学习存储过程的使用,点击按钮存数据。出现问题:adostoredproc1:parameters '@name'not found
建立了一个简单的表tb_test 字段有:name, sex 两个,均为char(10),
建立存储过程mystoredproc
create proc myprocedproc
@name char(10)
@sex char(10)
as
begin
insert into tb_test (name,sex)values(@name,@sex);
end;
检查语法没错
打开delphi新建工程。通过adoconnection 与数据库建立连接。添加adostoredproc1 procname 指定为 mystoredproc.
点击按钮事件中
with adostoredproc1 do
begin
parameters.parambyname('@name').value:='xiaowang';
parameters.parambyname('@sex').value:='nan';
execproc;
end;
运行出错:adostoredproc1:parameters '@name'not found
@name char(10) // 这里少了逗号吧 重建一次看看
@sex char(10)
as
begin
insert into tb_test (name,sex)values(@name,@sex);
end; //我不用adostoredproc1的,程序里不太清楚,应该OK吧
2. 程序改成:with adoStoredProc1 do
begin
Close;
ProcedureName := 'mystoredproc';
Parameters.Refresh;
Parameters.ParamByName('@name').Value := 'xiaowang';
Parameters.ParamByName('@sex').Value := 'nan';
ExecProc;
end;
begin
if active then close;
sql.clear;
sql.text :='exec myprocedproc :name,:sex';
parameters.paramByName('Name').value='xiaowang';
parameters.paramByName('sex').value= 'nan';
ExecSql;
end;