function TDataModule1.PipeNameExists(PName: string; var ID: Integer): Boolean;
var
RC: Integer;
begin
ADOQuery1.SQL.Text := 'select Pipe_ID from Comp_Pipe_Name where Pipe_Name=:Pn';
ADOQuery1.Parameters.ParamByName('Pn').Value := PName;
ADOQuery1.Open;
RC := ADOQuery1.RecordCount;
if RC>0 then
ID := ADOQuery1.FieldByName('Pipe_ID').AsInteger;
//Result := (RC>0);
end;
PS:这段程序是在Datamodual下编的
我想判断一下,当我在ComboBox1里输入字符时,是否有重复;
----------------------------------------------------------------------------------
Pn := InputDlg.ComboBox1.Text;
with DataModule1.ADOQuery1 do
begin
Close;
SQL.Clear;
if not DataModule1.PipeNameExists(Pn, PipeID) then
begin
SQL.Add('Insert Comp_Pipe_Name(Pipe_Name) Values(:a) select @@IDentity as ID');
Parameters.ParamByName('a').value:= InputDlg.ComboBox1.Text;
Open;
PipeID := FieldByName('ID').AsInteger;
ShowMessage(Format('最近插入的是%d',[PipeID]));
end;
这段是主程序的代码,如果没输入重复,则执行下面操作,运行后,可以编译,但操作报错,"'ADOQuery1:Field 'ID' not found'"
请问是什么原因?
var
RC: Integer;
begin
ADOQuery1.SQL.Text := 'select Pipe_ID from Comp_Pipe_Name where Pipe_Name=:Pn';
ADOQuery1.Parameters.ParamByName('Pn').Value := PName;
ADOQuery1.Open;
RC := ADOQuery1.RecordCount;
if RC>0 then
ID := ADOQuery1.FieldByName('Pipe_ID').AsInteger;
//Result := (RC>0);
end;
PS:这段程序是在Datamodual下编的
我想判断一下,当我在ComboBox1里输入字符时,是否有重复;
----------------------------------------------------------------------------------
Pn := InputDlg.ComboBox1.Text;
with DataModule1.ADOQuery1 do
begin
Close;
SQL.Clear;
if not DataModule1.PipeNameExists(Pn, PipeID) then
begin
SQL.Add('Insert Comp_Pipe_Name(Pipe_Name) Values(:a) select @@IDentity as ID');
Parameters.ParamByName('a').value:= InputDlg.ComboBox1.Text;
Open;
PipeID := FieldByName('ID').AsInteger;
ShowMessage(Format('最近插入的是%d',[PipeID]));
end;
这段是主程序的代码,如果没输入重复,则执行下面操作,运行后,可以编译,但操作报错,"'ADOQuery1:Field 'ID' not found'"
请问是什么原因?
解决方案 »
- Delphi导出问题
- 获取操作系统信息的问题
- 大家帮我看看,我的TreeView为什么只能取出部分数据.立即揭帖
- 字符串查找问题!
- 哪里有比TSpcom更好的专业读写串口控件(不需要注册的)
- 急!急!急!如何在打印时设置纸张的大小?请各位帮帮忙!诚谢!
- 急,主从表的问题,在线等候,(已经困扰三天了)
- 报表打开的时候缺省为最大化状态,怎么样为设计时候状态?
- 我截获我窗口的消息,来自己处理这个函数怎么写的在delphi里面
- **************为将要编写的kylix开发书籍收集意见******************
- [游戏]渔人之利,大家活跃一下
- 您好,我使用了ColorMatrix进行图像的反色,对于有些彩色图像是正确的,而有些则有一些噪点,能帮我诊断下吗?
var
RC: Integer;
begin
ADOQuery1.SQL.Text := 'select Pipe_ID from Comp_Pipe_Name where Pipe_Name=:Pn';
ADOQuery1.Parameters.ParamByName('Pn').Value := PName;
ADOQuery1.Open;
RC := ADOQuery1.RecordCount;
if RC>0 then
ID := ADOQuery1.FieldByName('Pipe_ID').AsInteger;
//Result := (RC>0);
ADOQuery1.Close;
end;
PS:这段程序是在Datamodual下编的
我想判断一下,当我在ComboBox1里输入字符时,是否有重复;
----------------------------------------------------------------------------------
Pn := InputDlg.ComboBox1.Text;
with DataModule1.ADOQuery1 do
begin
Close;
SQL.Clear;
if not DataModule1.PipeNameExists(Pn, PipeID) then
begin
//SQL.Add('Insert Comp_Pipe_Name(Pipe_Name) Values(:a) select @@IDentity as ID');
SQL.Add('Insert Comp_Pipe_Name(Pipe_Name) Values(:a) select @@IDentity as ID');
Parameters.ParamByName('a').value:= InputDlg.ComboBox1.Text;
Open;
PipeID := FieldByName('ID').AsInteger;
ShowMessage(Format('最近插入的是%d',[PipeID]));
end;
这段是主程序的代码,如果没输入重复,则执行下面操作,运行后,可以编译,但操作报错,"'ADOQuery1:Field 'ID' not found'"
请问是什么原因?
var
RC: Integer;
begin
ADOQuery1.SQL.Text := 'select Pipe_ID from Comp_Pipe_Name where Pipe_Name=:Pn';
ADOQuery1.Parameters.ParamByName('Pn').Value := PName;
ADOQuery1.Open;
RC := ADOQuery1.RecordCount;
if RC>0 then
ID := ADOQuery1.FieldByName('Pipe_ID').AsInteger;
//Result := (RC>0);
ADOQuery1.Close;
end;
PS:这段程序是在Datamodual下编的
我想判断一下,当我在ComboBox1里输入字符时,是否有重复;
----------------------------------------------------------------------------------
Pn := InputDlg.ComboBox1.Text;
with DataModule1.ADOQuery1 do
begin
Close;
SQL.Clear;
if not DataModule1.PipeNameExists(Pn, PipeID) then
begin
//SQL.Add('Insert Comp_Pipe_Name(Pipe_Name) Values(:a) select @@IDentity as ID');
SQL.Text := 'Insert Comp_Pipe_Name(Pipe_Name) Values(:a) select @@IDentity as ID';
Parameters.ParamByName('a').value:= InputDlg.ComboBox1.Text;
Open;
PipeID := FieldByName('ID').AsInteger;
ShowMessage(Format('最近插入的是%d',[PipeID]));
end;
这段是主程序的代码,如果没输入重复,则执行下面操作,运行后,可以编译,但操作报错,"'ADOQuery1:Field 'ID' not found'"
请问是什么原因?
SQL.Add('Insert Comp_Pipe_Name(Pipe_Name) Values(:a) select @@IDentity as ID');
--------------------------------------------------------------------------------------------
SQL.Text := 'Insert Comp_Pipe_Name(Pipe_Name) Values(:a) select @@IDentity as ID';
======================================================================
怎么改呢?
你可以把Clear,写在PipeNameExists判断之后.试试!!
--------------------------------------------------------------------------------------------
SQL.Text := 'Insert Comp_Pipe_Name(Pipe_Name) Values(:a) select @@IDentity as ID'; 这两句是可以通用的,但如果SQL已经赋值过,用SQL.Add前,先调用SQL.Clear。上面有人说过。