string sql="select a.name,a.email,a.telephone,a.discountid,b.discountname a.memo from passenger a,discount b where a.discountid=b.discountid and a.personcard="+Txtpercard.Text.ToString();好像有错!不能这样写

解决方案 »

  1.   

    先在查询分析器里试试上面的SQL语句是不是正确阿
      

  2.   

    改成
    string sql="select a.name,a.email,a.telephone,a.discountid,b.discountname,a.memo from passenger a,discount b where a.discountid=b.discountid and a.personcard="+Txtpercard.Text.ToString();
      

  3.   

    改成:
    sql="select a.name,a.email,a.telephone,a.discountid,b.discountname,a.memo from passenger a,discount b where a.discountid=b.discountid and a.personcard='"+Txtpercard.Text.ToString()+"'";
      

  4.   

    sql语句错误
    在最后面的Txtpercard.Text.ToString()错了,string类型要在sql语句中加上单引号另外,你的这个语句中(我指的是C#),不需要在Txtpercard.Text后面加上ToString(),因为那个已经是string了