var str_0:string;str_0:='select * from 用户表 where 用户名='''+Quotedstr(edit1.Text)+''' and 密码='''+quotedstr(edit2.Text)+'''';
edit2.Text:=str_0;                                       //edit1为用户名 edit2为密 
ADOQuery1.SQL.Add(str_0);                  //到这有错误,从理论上应该没有,可过不去我调试了一下,比如用户名为123,密码为456,str_0='select from 用户表 where 用户名="123" and 密码="456"   我把ADOQuery1.SQL.Add(str_0)中的str_0改为上过的值就好使了,不知道是为什么。可加答一下。

解决方案 »

  1.   

    到这有错误,什么错误?改为上过的值?什么意思?下面这样试一下with adoquery1 do
    begin
       close;
       sql.clear;
       str_0:='select * from 用户表 where 用户名=%s and 密码=%s'; 
       str_0:=Format(str_0,[QuotedStr(edit1.Text),QuotedStr(edit2.Text)]);
       SQL.Add(str_0); 
       open;                 
    end;
      

  2.   

    你的'''用多了
    str_0:='select * from 用户表 where 用户名='+Quotedstr(edit1.Text)+' and 密码='+quotedstr(edit2.Text);
      

  3.   

    procedure TForm1.BitBtn1Click(Sender: TObject);
     var str_0:string;
    begin  adoquery1.Close;
      adoquery1.SQL.Clear;
      str_0:='select * from 用户表 where 用户名=:a and 密码=:b';
      ADOQuery1.SQL.Add(str_0);
      adoquery1.Parameters.ParamByName('a').Value:=edit1.Text;
      adoquery1.Parameters.ParamByName('b').Value:=edit2.Text;
      adoquery1.Open;
    end;
    这样写吧,测试过可以行的
      

  4.   

    edit2.Text:=str_0;  为什么要这样做啊?有什么意义吗?
    用sql作为密码?
      

  5.   

    改为str_0:='select * from 用户表 where 用户名= '+Quotedstr(edit1.Text)+' and 密码='+quotedstr(edit2.Text);
      

  6.   

    改为str_0:='select * from 用户表 where 用户名= '+Quotedstr(edit1.Text)+' and 密码='+quotedstr(edit2.Text);