假设查询的结果用DATAGRID的控件显示出来,怎样把这个查询的结果
显示在DataReport报表中如果
Set DataReport1.DataSource = 我的查询的结果集
DataReport1.Show如何定义我的查询的结果集(需要详细源代码)

解决方案 »

  1.   

    dim sql as string
    sql ="sql语句"
    If DataEnvironment1.rsCommand3.State <> adStateClosed Then
       DataEnvironment1.rsCommand3.Close
    End If
    If Right$(Trim$(App.Path), 1) = "\" Then
       DataEnvironment1.Connection1.Open App.Path & "数据库"
     Else
       DataEnvironment1.Connection1.Open App.Path & "\数据库"
    End If
       DataEnvironment1.rsCommand3.Open sql
    Set DataReport5.DataSource = DataEnvironment1
        DataReport5.DataMember = "command3"
        DataReport5.Show
    这里面command3和datareport5 根据你的实际情况来写
    command3是在数据环境设计器中添加的
      

  2.   

    比较日期:convert(char(8),getdate(),112)>convert(char(8),'2003-01-01',112)计算月份:如:select month(getdate()) - month('2003-01-01')  结果是:5