SelectSqlServer:='select * from userName where usernames="'+Txtusername+'"';//提示Txtusername值列名无效!真是想不通啊!
      form1.ADOQuery2.Close;
      form1.ADOQuery2.SQL.Clear;
      form1.ADOQuery2.SQL.Add(SelectSqlServer);
      form1.ADOQuery2.open;
      TxtName:=form1.ADOQuery2.Parameters.ParamByName('UserNames').Value;

解决方案 »

  1.   

    看不明白,建议楼主把语句贴多些.可参考下面语句
           ADOquery1.SQL.Clear;
          ADOquery1.SQL.Add('select  *  from stuinfo  where 学号=:xh');
          ADOquery1.Parameters.ParamByName('xh').Value:=trim(edit1.Text);
          Adoquery1.Open;
          
      

  2.   

    SelectSqlServer:='select * from userName where usernames="'+Txtusername+'"';//提示Txtusername值
    改写
    SelectSqlServer:='select * from userName where usernames='+quotedstr(Txtusername)
    或者
    SelectSqlServer:='select * from userName where usernames='''+Txtusername+'''';(全部用单引号)
      

  3.   

    应该是字符串的拼接错误吧,连接符号用单引号。SelectSqlServer:='select * from userName where usernames='''+Txtusername+''' ';
    or
    SelectSqlServer:='select * from userName where usernames=:userstr';
    {考虑一楼的办法}