数据库连接没有错误,只是找不到表中的信息.(比如航班号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;

解决方案 »

  1.   

    adoquery1.SQL.add('select * from 查询表 where(航班号=:001)');
    应写成
    adoquery1.SQL.add('select * from 查询表 where(航班号=001)');
      

  2.   

    冒号开头表示SQL中的变量了,不是常数!
      

  3.   

    adoquery1.SQL.add('select * from 查询表 where 航班号='+#39+'001'+#39);
      

  4.   

    我试了一下还是不行,是不是少了ecexsql 语句,它应加在哪?
      

  5.   

    adoquery1.Close;
    adoquery1.SQL.Clear;
    adoquery1.SQL.add('select * from 查询表 where 航班号=''001'' ');
    adoquery1.Open;(注:常量要用两个单引号括起来)
      

  6.   

    with ADOQuery1 do begin
      SQL.Clear;
      SQL.Add('select * from 查询表 where 航班号=:var1 ');
      Parameters.Clear;
      Parameters.AddParameter.Name := 'var1';         //参数定義
      Parameters.ParamByName('var1').Value := '001' ; //参数付値
      Open; 
    end;(注:其实你的问题可以用参数方式更灵活...)
      

  7.   

    我正想问着样可以吗
    hbh:=trim(edit2.Text);
    adoquery1.SQL.add('select * from 查询表 where(航班号:=hbh)');