关于数据库表格存入数据的小问题!
我想把ComboBox1里输入的内容存到数据表Comp_Pipe_Name的Pipe_Name字段中,存之前想判断一个数据库表里是否里已经存过这个记录,如 没存过再存入,判断过程我是在ComboBox1的OnExit事件中触发这个事件:代码如下:
procedure TInputDlg.ComboBox1Exit(Sender: TObject);
begin
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:='';
end;
end;
----------------------------------------------------------------------------------------
下面我想在主程序里调用这个函数(祝程序就是用来往数据库的表里存数据的),主程序是这样的:
begin
if InputDlg.ShowModal = mrok then
begin
Close;
SQL.Clear;
with DataModule1.ADOQuery1 do
begin
if not TInputDlg.ComboBox1Exit(string,Tobject) then-------------我感觉引用这好像不太对
SQL.Add('Insert Comp_Pipe_Name(Pipe_Name) Values(:a)');
Parameters.ParamByName('a').value:= InputDlg.ComboBox1.Text;
ExecSQL;
end;
end;
end;
-----------------------------------------------------------
结果编译不过去啊,[Error] digitizer_input.pas(69): Declaration expected but end of file found
请问高手是哪里的毛病呢,调用的不对,还是有逻辑错误。
procedure TInputDlg.ComboBox1Exit(Sender: TObject);
begin
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:='';
end;
end;
----------------------------------------------------------------------------------------
下面我想在主程序里调用这个函数(祝程序就是用来往数据库的表里存数据的),主程序是这样的:
begin
if InputDlg.ShowModal = mrok then
begin
Close;
SQL.Clear;
with DataModule1.ADOQuery1 do
begin
if not TInputDlg.ComboBox1Exit(string,Tobject) then-------------我感觉引用这好像不太对
SQL.Add('Insert Comp_Pipe_Name(Pipe_Name) Values(:a)');
Parameters.ParamByName('a').value:= InputDlg.ComboBox1.Text;
ExecSQL;
end;
end;
end;
-----------------------------------------------------------
结果编译不过去啊,[Error] digitizer_input.pas(69): Declaration expected but end of file found
请问高手是哪里的毛病呢,调用的不对,还是有逻辑错误。
...全文
相关推荐
DB(数据库查看器)
DB数据库查看器 可查询paradox及dbf数据库文件内容。
利用datagridview控件实现批量输入数据并存入数据库
利用datagridview控件实现批量输入数据并存入数据库
查看android的数据库文件db工具
可以查看android的数据库文件db工具
NET写的一个数据仓库表格和一个数据库表表格源代码.
两个表格的源代码,一个是面向数据仓库的.一个是面向数据库的.两价目表格都有源程序及例子.欢迎下载!
手机备份db数据、db数据库文件查看器(windows版本)
方便查看db数据库以及手机备份db数据库(手机备份时,一定不能加密备份,否则无法查看),手机备份的数据先要用手机辅助工具导到电脑哦。


数据库相关

