小弟刚学delphi 做个登陆的
procedure TForm1.Button1Click(Sender: TObject);
begin
  if(trim(Edit1.Text) <> '') and (trim(Edit2.Text) <> '') then
   begin
      with DataModule3 do
      begin
        ADOConnection1.Open;
        ADOQuery1.Close;
        ADOQuery1.SQL.Clear;
        ADOQuery1.SQL.Add('select * from Tab_UserInfo where UserName='+ Edit1.Text +' and PassWord='+ Edit2.Text +'');
        ADOQuery1.Open;
        if ADOQuery1.IsEmpty then
        begin
          MessageBox(GetActiveWindow(),'用户名或密码错误!','警告',MB_Ok);
          ADOQuery1.Close;
          Exit;
        end
        else
        begin
          Form2.Show;
        end;
      end;
   end;
end;运行的时候说 无法找到"xxx"列  xxx是输入Edit1的Text
大侠指点

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      if(trim(Edit1.Text) <> '') and (trim(Edit2.Text) <> '') then
       begin
          with DataModule3 do
          begin
            ADOConnection1.Open;//这句可省略
            ADOQuery1.Close;
            ADOQuery1.SQL.Clear;
            ADOQuery1.SQL.Add('select * from Tab_UserInfo where UserName='+ quotedstr(Edit1.Text) +' and PassWord='+ quotedstr(Edit2.Text));
            ADOQuery1.Open;
            if ADOQuery1.IsEmpty then
            begin
              MessageBox(GetActiveWindow(),'用户名或密码错误!','警告',MB_Ok);
              ADOQuery1.Close;
              Exit;
            end
            else
            begin
              Form2.Show;
            end;
          end;
       end;
    end;
      

  2.   


            ADOQuery1.SQL.Add('select * from Tab_UserInfo where UserName='+ QuotedStr(Edit1.Text) +' and PassWord='+ QuotedStr(Edit2.Text));