http://www.wzjcw.net/vbgood/taishan/index.html

解决方案 »

  1.   

    在程序中,动态设定datareport的
    Dim rs As New ADODB.Recordset
    cn = "Provider = Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=D:\my\db_stu.mdb"
    rs.Open strSql, cn, 3, 1         ‘strsql"为显示某个表的sql命令。
      

  2.   

    DATAREPORT是数据绑定控件,所以它数据不能完全由应用程序直接写入(可以部分,但一定要有数据源),它必须与一个RECORDSET绑定在一起。
    用下面的方法可以向DATAREPORT直接写数据
    DataReport1.Sections("Section2").Controls("Label1").Caption="数据报表"如果需要在报表中显示两个表,你需要在RECORDSET的SQL中使用JOIN来连接两个表,使用两个表的字段同时显示在报表上。详情可以参考T-SQL的说明。
    select a.*,b.name from table1 a join table2 b on a.id=b.id