unit aa;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, DB,ADODB;type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Label1: TLabel;
    Label2: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;
  LogTimes: Integer;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
  logtimes:=0;
end;procedure TForm1.BitBtn1Click(Sender: TObject);
var
ADOQuery1:TADOQuery;
begin
ADOQuery1:= TADOQuery.Create(self);
ADOQuery1.ConnectionString :='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initi' +
      'al Catalog=XD;Data Source=bb';
 ADOQuery1.SQL.Clear;
 ADOQuery1.SQL.Add('select * from usepass where 帐号="'+edit1.Text+'" and 密码="'+edit2.Text+'" ');
    ADOQuery1.Open;
    if ADOQuery1.Eof then
    begin
    messagebox(handle,'您没有填写用户和密码!','出错提示',mb_iconinformation+mb_ok);
    edit1.SetFocus;
    end
    else
    begin
    messagebox(handle,'欢迎进入!','登陆成功',mb_iconinformation+mb_ok);
    end
end;end.
出错提示:列名无效!

解决方案 »

  1.   

    ADOQuery1.SQL.Add('select * from usepass where 帐号="'+edit1.Text+'" and 密码="'+edit2.Text+'" ');~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ADOQuery1.SQL.Add('select * from usepass where 帐号='''+edit1.Text+''' and 密码='''+edit2.Text+'''');
    "  ''
      

  2.   

    你都sql语句有问题
     ADOQuery1.SQL.Add('select * from usepass where 帐号="'+edit1.Text+'" and 密码="'+edit2.Text+'" ');怎么会出现双引号呢??
      

  3.   

    'select * from usepass where 帐号='''+edit1.Text +''' and 密码='''+edit2.Text+'''';不要用双引号
      

  4.   

    如上所说,
    调试中,最好showmessage一下,showmessage("'+edit1.Text+'")看看出来什么.
      

  5.   

    谢谢问题解决。我用DGRI显示数据库中的数据,用那个控件好一点。请把用法写上。谢谢!
      

  6.   

    直接用dbgrid好了﹐多省事。用第三方控件還得安裝
      

  7.   

    'select * from usepass where [帐号]='''+edit1.Text+''' and [密码]='''+edit2.Text+''' ';