with UntPub.myAdoQuery do
    begin
       close;
       sql.clear;
       strSQL:='select Pass from syms.USER_LIST where USERID=''' +trim(self.EUser.text)+'''';
       sql.add(strsql);
       //test
       if myAdoQuery.Connection.Connected=true then//判断是否已经连接上
       begin
          untpub.MsgBox(myAdoQuery.SQL.Text);//把sql语句显示出来
          txtSql.Text:=myAdoQuery.SQL.Text;
       end;
       open;
       first;
       if myAdoquery.IsEmpty=true then  //判断结构是否为空
        untpub.MsgBox('结果为空!');
    if RecordCount<1 then
    begin
      untpub.MsgBox('用户'+trim(self.EUser.text)+'不存在!');
      close;
      exit;
    end;
各位高手帮帮忙,看看我这个问题出现在哪了,数据库已经连接上了,但在Open后myAdoquery为空,是sql语句出了问题吗?但是在pl、sql里面执行没有问题啊 

解决方案 »

  1.   

    流程上有问题啊。
    应该类似这样
     select * from syms.USER_LIST where USERID= YourID
    //.....
    if myAdoquery.IsEmpty then //用户不存在
    else
      begin
        //取密码
        Pass := FieldByName('Pass').AsString;
      end 
      

  2.   


    看我下面这段代码,应该不是你说的问题
    with UntPub.myAdoQuery do 
        begin 
          close; 
          sql.clear; 
          strSQL:='select Pass from syms.USER_LIST where USERID=''' +trim(self.EUser.text)+''''; 
          sql.add(strsql); 
          //test 
          if myAdoQuery.Connection.Connected=true then//判断是否已经连接上 
          begin 
              untpub.MsgBox(myAdoQuery.SQL.Text);//把sql语句显示出来 
              txtSql.Text:=myAdoQuery.SQL.Text; 

          end; 
          open; 
          first; 
          if myAdoquery.IsEmpty=true then  //判断结构是否为空 
            untpub.MsgBox('结果为空!'); 

        if RecordCount <1 then 
        begin 
          untpub.MsgBox('用户'+trim(self.EUser.text)+'不存在!'); 
          close; 
          exit; 
        end; 
    灰色部分只是我用来查看程序运行过程的
      

  3.   

    你把strSQL显示出来看看,拷贝到SQL/PL中试验一下看看不论是ADO还是ODAC,都不会有这样的BUG.