select title,cname,pubdate,hits from newscat,news where newscat.id=news.catid
我的sql语句如上?????

解决方案 »

  1.   

    string sql="select title,cname,pubdate,hits from newscat,news where newscat.id=news.catid";
    objAdapter.Fill(objDataSet, tablename);
    DataSet ds=objDataSet;
    newslist.DataSource=ds;
    newslist.DataMember="news";
    newslist.DataBind();
      

  2.   

    与tablename没有关系,报什么错?
      

  3.   

    更正:objAdapter.Fill(objDataSet, "news");
      

  4.   

    首先
    string sql="select title,cname,pubdate,hits from newscat,news where newscat.id=news.catid";->string sql="select title,cname,pubdate,hits from newscat,news where newscat.id="+news.catid;你要用sql构造SqlCommand来初始化objAdapter的SelectCommand