求助:'Query2:Parameter 'bh' not found'
程序如下:
procedure TFkxxForm.BitBtn4Click(Sender: TObject);
var
sqlstr:string;
begin
try
if edit1.Text='' then
begin
Application.MessageBox('请填写用户编号','提示',MB_OK+MB_ICONINFORMATION);
Edit1.SetFocus ;
exit;
end;
if Edit2.Text='' then
begin
Application.MessageBox('请填写客户姓名','提示',MB_OK+MB_ICONINFORMATION);
edit2.SetFocus ;
exit;
end;
if Edit3.Text='' then
begin
Application.MessageBox('请填写客户身份证号','提示',MB_OK+MB_ICONINFORMATION);
edit3.SetFocus ;
exit;
end;
if Edit5.Text ='' then
begin
Application.MessageBox('请填写联系电话','提示',MB_OK+MB_ICONINFORMATION);
edit5.SetFocus ;
exit;
end;
if Edit6.Text='' then
begin
Application.MessageBox('请填写客户地址','提示',MB_OK+MB_ICONINFORMATION);
edit6.SetFocus ;
exit;
end;
query2.Close;
query2.SQL.Clear;
if flag=1 then
sqlstr:='insert into custom values(:bh,:xm,:xb,:sfz,:dw,:dz,:dh)'
else
if flag=2 then
begin
sqlstr:='update custom set 编号=:bh,姓名=:xm,性别=:xb,身份证=:sfz,'
+'单位=:dw,地址=:dz,电话=:dh where 编号=:oldbh';
query2.ParamByName('oldbh').AsString:=query1.FieldValues['编号'];
end;
query2.ParamByName('bh').AsString:=edit1.Text; //后面出错的地方说的‘bh’就是这里的‘bh’
query2.ParamByName('xm').AsString:=edit2.Text;
query2.ParamByName('xb').AsString:=comboBox1.Text;
query2.ParamByName('sfz').AsString:=edit3.Text;
query2.ParamByName('dw').AsString:=edit4.Text;
query2.ParamByName('dz').AsString:=edit5.Text;
query2.ParamByName('dh').AsString:=edit6.Text;
query1.ExecSQL;
if query1.Active then
query1.Close;
query1.Open;
//end
except
begin
MessageBox(0,'数据操作失败,可能有重复的用户编号!','',MB_OK+MB_ICONERROR);
exit;
end;
end;
enabledfalse;
bitbtn1.Enabled:=true;
bitbtn2.Enabled:=true;
bitbtn3.Enabled:=true;
end;
这个是保存按钮的实现功能,但是运行的时候总是提示:
Project FwczMis.exe raised exception class EDatabaseError with message 'Query2:Parameter 'bh' not found'. Process stopped .Use Step or Run to continue'...
各位大侠帮帮忙哦,这是为什么啊?