苏州阊胥路北大青鸟 北大青鸟苏州阊胥路标准化校区
  书香社区·书香博客·联系我们  
全国免费电话:400-888-1050
 
首页 | 新闻动态 | 学校介绍 | 课程详解 | 师资力量 | 学习园地 | 就业广场 | 开发技术 | 校区招聘
  在线报名 在线留言  
   
您的位置:首页 - .NET技术  
vb.net获取服务器报表数据(二)  
2009-11-24  发布人:殷振华  浏览次数::
        在上一篇文章中,我们讲到了如何利用CrystalReport提供的API登录到报表服务器,今天我们讲解,在登录到服务器之后如何获取报表服务器中的数据。
        如何获取报表服务器上的报表,在这里我采取的是采用的是CrystalReport中的"InfoStore"API所提供的QUERY方法来查询报表的方式获取的,这里主要又涉及到了数据库的查询语句的组织,关于数据库的查询,不是我们这里所要讨论的问题,在此略过。下面,我们借助于具体的代码,来分析Query方法如何使用。
        '//The search event
    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        'Clear the list box
        Me.lstResults.Items.Clear()
        Dim reportName As String = String.Empty
        Dim strQuery As String = String.Empty
        strQuery = "select * from CI_INFOOBJECTS where SI_INSTANCE = 1 and SI_RECURRING = 1 and SI_NAME='" + Me.txtSI_NAME.Text + "'"
        'Select the reports by the strQuery
        m_infoReports = ceInfoStore.Query(strQuery)
        'Release the control right
        Application.DoEvents()
        'Validate the results count.
        'If the count less than 1 then show message "There is 0 record(s)" and exit the program
        If m_infoReports.Count < 1 Then
            Me.lSearchResult.Text = "There are " + m_infoReports.Count.ToString() + " record(s)"
            Return
        End If
        Me.btnSaveFile.Enabled = True
        Me.lSearchResult.Text = "There are " + m_infoReports.Count.ToString() + " record(s)"
        'About all the InfoObject in the InfoObject collection
        'Add their names to the listbox
        For Each m_infoReport In m_infoReports
            Application.DoEvents()
            ProgressCount()
            reportName = m_infoReport.ID.ToString() + "->" + m_infoReport.Title
            Me.lstResults.Items.Add(reportName)
        Next
    End Sub
        在上述的代码中,查询语句strQuery 后面的条件,是每一个我们要设置的参数,比如SI_INSTANCE = 1表示的是这个Instance是子文件.InfoStore.Query()方法的返回值是一个Report集合,所以,我们定义了一个m_infoReports 数组变量来存放方法的返回值,最后使用一个Foreach循环,来遍历数组中的报表内同,并把相关的数据写入到ListView中。
        在这两篇中,一直没有提到过所使用的技术平台,这里所使用的技术平台是:VS2003+vb.net
 
设为首页 | 加入收藏 | 联系我们 | 联系站长 | 友情链接
报名咨询:0512-65566661 65566662   备案许可证号:苏ICP备09076008号
地址:苏州市阊胥路483号创元科技园6号楼1层(干将西路友通数码港向北100米)
交通路线:6、7、7路区间、64、70、88、262、300、303、304、307、318、332、333、333路龙池专线、
522、800、921、932、949.(小日晖桥北站)