if Query.RecordCount = 0 then
  ShowMsg('登录失败,请检查一下用户名和密码是否正确!')
else
  ShowMsg('登录成功!');本人菜鸟,在做用户登录界面时,用到SQLQuery,在对用户名、密码和Oracle9i中的资料进行核查时,报错:表或视图不存在。数据库连接无问题。经过在网上搜索,说是此处写法不对,但不知道如何修正。我只在登录界面用了一个SQLQuery组件,其SQLConnection属性是uses另一个DataModule中的SQLConnection。请各位指点一下,谢谢!

解决方案 »

  1.   

    你的SQL语句是怎样的,请帖出来看看,ORICAL中的SQL语句和T-SQL有些不一样
      

  2.   

    if Query.Active then
    begin
    if Query.RecordCount = 0 then
      ShowMsg('登录失败,请检查一下用户名和密码是否正确!')
    else
      ShowMsg('登录成功!');
    end
    else
    begin
      ShowMsg('数据库连接失败!');
    end;
      

  3.   

    pbcao(delphicao):
        使用Query.RecordCount = 0报错(和最初报错内容相同),报错内容如下Project SoftManager.exe raised exception class EDatabaseError with message 'SQLServer Error: ORA-00942: 表或视图不存在'.Process stopped.Use Step or Run to continue.
    其中SoftManager.exe是我的工程名。源码如下:
      PUser := UpperCase(edtLander.Text);
      PPwd := edtPwd.Text;
      PPwd := Encrypt(PPwd);
      Str := 'select * from sm_inf_lander where upper(landercode)=''' + PUser + ''' '
        + 'and password=''' + PPwd + '''';
      Query.Close;
      Query.SQL.Text := Str;
      Query.Open;
      if Query.RecordCount > 0 then
      //if Query.IsEmpty then
      //if Query.Eof then
         //ShowMsg('登录失败,请检查一下用户名和密码是否正确!')
         ShowMsg('登录成功!')
       else
         //ShowMsg('登录成功!');
         ShowMsg('登录失败,请检查一下用户名和密码是否正确!');
      end;
      

  4.   

    Oracle 好象是大小写区分的 你的表名写对了没?
      

  5.   

    关键是SQLQuery.RecordCount有问题,如果是ADOQuery.RecordCount就没有问题。
    因为是用dbExpress连接oracle数据库,所以不用ADOQuery。
    网上有人说可能是SQLQuery的BUG,用SQLQuery+DataSetProvider+ClientDataSet可以解决,但我不知道具体怎么操作。我用的是Delphi7.0,已打过所有补丁。
      

  6.   

    试试这样:  PUser := UpperCase(edtLander.Text);
      PPwd := edtPwd.Text;
      PPwd := Encrypt(PPwd);
      Str := 'select count(*) from sm_inf_lander where upper(landercode)=''' + PUser + ''' '
        + 'and password=''' + PPwd + '''';
      Query.Close;
      Query.SQL.Text := Str;
      Query.Open;
      if Query.Fields[0].asInteger > 0 then
      //if Query.IsEmpty then
      //if Query.Eof then
         //ShowMsg('登录失败,请检查一下用户名和密码是否正确!')
         ShowMsg('登录成功!')
       else
         //ShowMsg('登录成功!');
         ShowMsg('登录失败,请检查一下用户名和密码是否正确!');
      end;
      

  7.   

    dragonki(dragonki):
    表名没有问题,在查询分析器有返回结果。larruping(诸相非相) :
    if Query.Fields[0].asInteger > 0 then报错:Query:Operation not allowed on a  unidirectional dataset.
    不允许单向数据集。
      

  8.   

    无法编辑回复啊!larruping(诸相非相) :
    刚才我搞错了,if Query.Fields[0].asInteger > 0 then报错:'' is not a valid integer value
      

  9.   

    count(*)的结果不可能为空,最起码都得为零
      

  10.   

    ShowMessage(Str);我估计结果会雷死你。