1.绑定的方法  ks myReport = new ks;
  myReport.SetDataSource(ds_pttpt.tables(0));
  CViewer_gj.ReportSource=myReport;
  CViewer_gj.RefreshReport()2.须注意,xsd数据集中的数据表 和 dataset.tables(0)中的数据表 完全相同才可

解决方案 »

  1.   

    ks myReport = new ks;
    这段代码可行吗?我的vs没法这样应用报表啊?
      

  2.   

    给一个例子参考:Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim sRptFile As String
            Dim oRpt As New ReportDocument ' create a reportDocument object first        'oRpt.Refresh() ' clear the old info
            getAuthorData()
            sRptFile = Server.MapPath("Report.rpt") ' assign the rpt file name , if in different directory , you must specify the absoluted URL
            oRpt.Load(sRptFile)
            oRpt.SetDataSource(getAuthorData)        CRViewer.ReportSource = oRpt
            'CrystalReportViewer1.DisplayGroupTree = False    End Sub    Private Function getAuthorData() As DataSet
            Dim oDS As New DataSet
            Dim oConn As New SqlConnection
            oConn.ConnectionString = "server=你的SERVER;database=pubs;user=sa;pwd=sa"
            oConn.Open()        Dim oCmd As New SqlCommand
            oCmd.CommandText = "select au_id,au_lname,au_fname,phone,address from authors"
            oCmd.CommandType = CommandType.Text
            oCmd.Connection = oConn        Dim oAdapter As New SqlDataAdapter(oCmd)        oAdapter.Fill(oDS)        oCmd.Dispose()
            oAdapter.Dispose()
            oConn.Close()
            oConn.Dispose()
            oDS.Tables(0).TableName = "authors_tbl" ' Note' the table name must the same as the table name you specify in the xsd file        Return oDS    End Function
      

  3.   

    我曾经听说:这个一个漏洞.得去水晶报表官方网站去down一个补丁就好了,我只是听说////////////////blackhero
      

  4.   

    BubbleKitty(BK):我的代码和你给的例子一样的啊,为什么不行?
      

  5.   

    2.须注意,xsd数据集中的数据表 和 dataset.tables(0)中的数据表 中的字段完全相同才可xsd数据集中的数据表名 和 dataset.tables(0)中的数据表名 也要完全相同---------------------------同意。。“xsd数据集中有表element1,在报表中拖放element1的字段自动成为IFieldObject”
    请问楼主在xsd数据集的表element1是否与 dataset.tables(0)中的数据表 完全相同??
    若相同的话,在设计报表的页面的时候,有没将此xsd数据集设为报表数据源?