一样的啦。
你直接把表与表之间的左联,右联,内联接写成一个SQL语句,或先写从一个视图再查询出来成一个DATASET传进去就可以了。然后你设计报表也照样把几个有关联的表拉过去,设一下是用哪个字段连接,进行相应的设计就可以了。
下面的例子供参考。protected void Page_Load(object sender, EventArgs e)
    {
        //连接字符在WEB.CONFIG获取
        string connStr = ConfigurationSettings.AppSettings["lj"].ToString();
        SqlDataSource datasource = new SqlDataSource(connStr, 你有SQL语句了,不管是关系到几个表都一样照传,主要你的报表有相应的设计就可以了);
        ReportDocument doc = new ReportDocument();
        TableLogOnInfo logininfo = new TableLogOnInfo();
        string path;
        
        path = Server.MapPath("report1.rpt");
        doc.Load(path);
        //强制连接数据库,在WEB.CONFIG获取
        string a, b, c, d;
        a = System.Configuration.ConfigurationManager.AppSettings[0];
        b = System.Configuration.ConfigurationManager.AppSettings[1];
        c = System.Configuration.ConfigurationManager.AppSettings[2];
        d = System.Configuration.ConfigurationManager.AppSettings[3];
        logininfo.ConnectionInfo.ServerName = a;
        logininfo.ConnectionInfo.DatabaseName = b;
        logininfo.ConnectionInfo.UserID = c;
        logininfo.ConnectionInfo.Password = d;        try
        {
            doc.Database.Tables[0].ApplyLogOnInfo(logininfo);
            doc.Database.Tables[0].SetDataSource(datasource.Select(DataSourceSelectArguments.Empty));
            CrystalReportViewer1.ReportSource = doc;
        }
        catch
        {
            Response.Write("<script>alert('输出报表失败,请检查输入信息或网络!');</script>");
        }    }

解决方案 »

  1.   

           string    sql="select * from App_Prject"  ;
    SqlDataAdapter  MyAdapter = new SqlDataAdapter(sql,MyConn);         MyAdapter.Fill(ds,"App_Prject");         oCR.SetDataSource(ds); 这是一个表的代码,多表的时候这句代码MyAdapter.Fill(ds,""); 这里引号里面填什么呢。
      

  2.   

    其实不关MyAdapter.Fill(ds,""); 这句代码的问题,是在你的SQL里控制就行了,我打个比方啊。
    string sql="select a.*,b.字段 from App_Prject a,App_Prject1 b where a.id=b.id"; 
    SqlDataAdapter  MyAdapter = new SqlDataAdapter(sql,MyConn); 
    MyAdapter.Fill(ds,"App_Prject"); 
    oCR.SetDataSource(ds); 
    然后你的画报表的时候就是把两个表都拉下去设计啦。把两个表所需要的字段放进去就好了。一样的道理
      

  3.   

    哦,这样啊,那个xsd文件是不是把两个表拉进来就可以了啊,还要如何处理呢