数据库连接没有错误,只是找不到表中的信息.(比如航班号001已经存在,却显示没有查到的信息),
begin
adoconnection1:=Tadoconnection.Create(Self);
adoconnection1.ConnectionString :='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\db\机票预定系统.mdb;Persist Security Info=False';
adoconnection1.LoginPrompt:=false;
adoquery1:=Tadoquery.Create(Self);
adoquery1.Connection:=adoconnection1;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add('select * from 查询表 where(航班号=:001)');
adoquery1.Open;
if adoquery1.RecordCount>0 then
begin
adoquery1.SQL.Add('insert into 预定表(预定人身份证号,联系方式,预定航班号,舱位等级,机票价格)value(:sfzh,:lxfs,:hbh,:cwdj)');
showmessage('您已经成功的预定!');
end
else
ShowMessage('没有符合您要求的航班,或已经满座,请重查询系统中查询可以符合您的班机,在进行预定!'); end;
begin
adoconnection1:=Tadoconnection.Create(Self);
adoconnection1.ConnectionString :='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\db\机票预定系统.mdb;Persist Security Info=False';
adoconnection1.LoginPrompt:=false;
adoquery1:=Tadoquery.Create(Self);
adoquery1.Connection:=adoconnection1;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add('select * from 查询表 where(航班号=:001)');
adoquery1.Open;
if adoquery1.RecordCount>0 then
begin
adoquery1.SQL.Add('insert into 预定表(预定人身份证号,联系方式,预定航班号,舱位等级,机票价格)value(:sfzh,:lxfs,:hbh,:cwdj)');
showmessage('您已经成功的预定!');
end
else
ShowMessage('没有符合您要求的航班,或已经满座,请重查询系统中查询可以符合您的班机,在进行预定!'); end;
解决方案 »
- 用什么工具可以查看TObject.Create的反汇编代码?
- 请问在sql中如何将下列情况中的机号分别列出来
- TdxSpreadSheetBookReportLink是一个什么控件,在线给分啊
- ★咨询一个主从表的filter的问题★
- 有谁用过tAdoTable.clone(tAdoTAble) 方法吗,请教一下
- 怎么配置Email服务器啊??急用,马上结贴!!!!
- 今天写一个要写一个关于缩图的程序发现网上的缩图代码有问题!改了改!
- 怎么判断数据库中的某一字段相同值一共有几个?
- 出售成熟ERP管理软件源码
- 请问在 Delphi中如何用数据字典?
- 写一个没有窗体的DLL,如何动态创建SPCOMM?
- 關於RICHEDIT的使用問題,各位仁兄請進~!
应写成
adoquery1.SQL.add('select * from 查询表 where(航班号=001)');
adoquery1.SQL.Clear;
adoquery1.SQL.add('select * from 查询表 where 航班号=''001'' ');
adoquery1.Open;(注:常量要用两个单引号括起来)
SQL.Clear;
SQL.Add('select * from 查询表 where 航班号=:var1 ');
Parameters.Clear;
Parameters.AddParameter.Name := 'var1'; //参数定義
Parameters.ParamByName('var1').Value := '001' ; //参数付値
Open;
end;(注:其实你的问题可以用参数方式更灵活...)
hbh:=trim(edit2.Text);
adoquery1.SQL.add('select * from 查询表 where(航班号:=hbh)');