我在ComboBox中输入数据,存到表Comp_Pipe_Name的Pipe_Name字段中,存之前想判断一个数据库表里是否里已经存过这个记录,如没存过再存入,判断过程我是在ComboBox1的OnExit事件中触发这个事件:代码如下:
procedure TInputDlg.ComboBox1Exit(Sender: TObject);
begin
Result := True;
with DataModule1.ADOquery1 do
begin
close;
sql.clear;
sql.add('select * from Comp_Pipe_Name where field =:Pipe_Name');
parameters.ParamByName('Pipe_Name').value:=combobox1.text;
open;
end;
if DataModule1.ADOquery1.recordcount>0 then
begin
Application.messagebox('已经输入过此数据','提示',0+mb_iconquestion) ;
combobox1.setfocus;
combobox1.text:='';
Result := False;
end;
下面我想在主程序里调用这个函数(主程序就是用来往数据库的表里存数据的),主程序是这样的:
end;
begin
if InputDlg.ShowModal = mrok then
begin
Close;
SQL.Clear;----------------------------------------------
with DataModule1.ADOQuery1 do
begin
if InputDlg.ComboBox1Exit then ------------------------------
begin
SQL.Add('Insert Comp_Pipe_Name(Pipe_Name) Values(:a)');
Parameters.ParamByName('a').value:= InputDlg.ComboBox1.Text;
end;
end;
end;
end;
编译后提示出错:
[Error] digitizer_main.pas(292): Undeclared identifier: 'SQL'
[Error] digitizer_main.pas(295): Not enough actual parameters
希望高手帮助解答!!!!
procedure TInputDlg.ComboBox1Exit(Sender: TObject);
begin
Result := True;
with DataModule1.ADOquery1 do
begin
close;
sql.clear;
sql.add('select * from Comp_Pipe_Name where field =:Pipe_Name');
parameters.ParamByName('Pipe_Name').value:=combobox1.text;
open;
end;
if DataModule1.ADOquery1.recordcount>0 then
begin
Application.messagebox('已经输入过此数据','提示',0+mb_iconquestion) ;
combobox1.setfocus;
combobox1.text:='';
Result := False;
end;
下面我想在主程序里调用这个函数(主程序就是用来往数据库的表里存数据的),主程序是这样的:
end;
begin
if InputDlg.ShowModal = mrok then
begin
Close;
SQL.Clear;----------------------------------------------
with DataModule1.ADOQuery1 do
begin
if InputDlg.ComboBox1Exit then ------------------------------
begin
SQL.Add('Insert Comp_Pipe_Name(Pipe_Name) Values(:a)');
Parameters.ParamByName('a').value:= InputDlg.ComboBox1.Text;
end;
end;
end;
end;
编译后提示出错:
[Error] digitizer_main.pas(292): Undeclared identifier: 'SQL'
[Error] digitizer_main.pas(295): Not enough actual parameters
希望高手帮助解答!!!!
解决方案 »
- 在delphi里怎么把form1里的DBGride里的一条记录的数据送到form2的edit
- 一个字串在debug时,显示为:'字串A'#4#4#4,字串本身值为:字串A ,如何去掉后面的#4#4#4
- 那位哥们给我讲一讲拖拽操作怎样实现?
- 用DBGRID显示的数据,需要选取某些行进行打印,怎样实现呢?
- 保存工作区的内容,兄弟们进来给点建议
- 为何delphi6装起后只有delphi可用,bde admin和sql explorer等都用不了??重转痛苦啊
- 怎样在DBGRIDE 中加入图标?感谢!2分
- 在程序中怎样动态获得当前编辑框的输入法。(高手请进,解决立即给分)
- 为什么写入一系列数字(字符串形式)进文本文件,打开却是乱码?
- 如何删除图像的边缘像素
- 不能倒分真不爽,发个0分帖加点可用分
- 调用
下面我想在主程序里调用这个函数(主程序就是用来往数据库的表里存数据的),主程序是这样的:
end;
begin
if InputDlg.ShowModal = mrok then
begin
DataModule1.ADOQuery1.Close;
DataModule1.ADOQuery1.SQL.Clear;----------------------------------------------
with DataModule1.ADOQuery1 do
begin
if InputDlg.ComboBox1Exit then ------------------------------
begin
SQL.Add('Insert Comp_Pipe_Name(Pipe_Name) Values(:a)');
Parameters.ParamByName('a').value:= InputDlg.ComboBox1.Text;
end;
end;
end;
end;