L
lightninglu
Unregistered / Unconfirmed
GUEST, unregistred user!
VAR X:string;
try
iF CHECK1.Checked THEN X:='1';
IF NOT CHECK1.Checked THEN X:='0';
if datamodule1.DepCnn.InTransaction then datamodule1.DepCnn.RollbackTrans;
datamodule1.DepCnn.BeginTrans;
begin
datamodule1.QryDepart.SQL.Clear;
datamodule1.QryDepart.sql.Add('select count(*) as dpt_id from department_info where dpt_id='+''''+eid.Text+'''');
datamodule1.QryDepart.open;
if datamodule1.QryDepart.FieldByName('DPT_ID').AsInteger>1 then
Messagebox(0,pchar('123'),'1211',MB_OK+MB_iconwarning)
Else IF datamodule1.QryDepart.FieldByName('DPT_ID').AsInteger<=1 then
datamodule1.QryDepart.Insert;
datamodule1.QryDepart.FieldByName('dpt_id').AsString:=eid.Text;
datamodule1.QryDepart.FieldByName('dpt_name').AsString:=ename.Text;
datamodule1.QryDepart.FieldByName('dpt_id').AsBoolean:=strtobool(x);
datamodule1.QryDepart.Post;
//datamodule1.QryDepart.ExecSQL;
datamodule1.DepCnn.CommitTrans;
datamodule1.QryDepart.Refresh;
close;
end;
except
begin
MessageBox(0,pchar('Insert Failed!!!'),'Bath',mb_ok+mb_iconinformation);
datamodule1.DepCnn.RollbackTrans;
exit;
end;
运行时报错:query: field 'dpt_id' not found,
try
iF CHECK1.Checked THEN X:='1';
IF NOT CHECK1.Checked THEN X:='0';
if datamodule1.DepCnn.InTransaction then datamodule1.DepCnn.RollbackTrans;
datamodule1.DepCnn.BeginTrans;
begin
datamodule1.QryDepart.SQL.Clear;
datamodule1.QryDepart.sql.Add('select count(*) as dpt_id from department_info where dpt_id='+''''+eid.Text+'''');
datamodule1.QryDepart.open;
if datamodule1.QryDepart.FieldByName('DPT_ID').AsInteger>1 then
Messagebox(0,pchar('123'),'1211',MB_OK+MB_iconwarning)
Else IF datamodule1.QryDepart.FieldByName('DPT_ID').AsInteger<=1 then
datamodule1.QryDepart.Insert;
datamodule1.QryDepart.FieldByName('dpt_id').AsString:=eid.Text;
datamodule1.QryDepart.FieldByName('dpt_name').AsString:=ename.Text;
datamodule1.QryDepart.FieldByName('dpt_id').AsBoolean:=strtobool(x);
datamodule1.QryDepart.Post;
//datamodule1.QryDepart.ExecSQL;
datamodule1.DepCnn.CommitTrans;
datamodule1.QryDepart.Refresh;
close;
end;
except
begin
MessageBox(0,pchar('Insert Failed!!!'),'Bath',mb_ok+mb_iconinformation);
datamodule1.DepCnn.RollbackTrans;
exit;
end;
运行时报错:query: field 'dpt_id' not found,