如何在Crystal Reports中使用更新的datareader [英] How do you use an updated datareader in Crystal Reports

查看:57
本文介绍了如何在Crystal Reports中使用更新的datareader的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在尝试使用更新的数据源在我的水晶报告中使用。晶体报告数据源是vwMyView。我想修改vwMyView的内容并使用更新的数据源在crystal报表中使用。我怎么能这样做,语法是什么或有更好的方法来做到这一点。下面是我的代码,我应该添加什么。帮助





 公共  sub  PossibleEmployeeSalary 

Dim adoCmd As SqlClient.SqlCommand
Dim adoRdr 作为 SqlDataReader
Dim cryRpt 作为 ReportDocument

cryRpt.Load( C:\ TEMP \ REPORT1.RPT
尝试
adoCmd.Connection = adoConn
adoCmd.CommandType = CommandType.Text
adoCmd.CommandText = SELECT * FROM vwMyView
adoCmd.ExecuteReader()

while adoRdr.Read()
adoRdr( 薪水)= adoRdr( 薪水)* 0 05
adoRdr( )= adoRdr(
结束 while

CrystalReportViewer1.Zoom( 1
CrystalReportViewer1.Refresh()

Catch ex As 例外

结束 尝试

结束 Sub

解决方案

在刷新之前添加两行...



 cryRpt.setdatasource = dr 
crystalreportviewer1 .reportsource = cryRpt


Hi,

I am trying to use an updated datasource to be use in my crystal report. The crystal report datasource is vwMyView. I want to amend the contents of vwMyView and use the updated datasource to be used in the crystal report. How can I do this and what would the syntax be or is there a better way of doing this. Below is my code, what should I add. Help


Public sub PossibleEmployeeSalary

        Dim adoCmd As New SqlClient.SqlCommand
        Dim adoRdr As SqlDataReader
        Dim cryRpt As New ReportDocument

        cryRpt.Load("C:\TEMP\REPORT1.RPT")
        Try
            adoCmd.Connection = adoConn
            adoCmd.CommandType = CommandType.Text
            adoCmd.CommandText = "SELECT * FROM vwMyView"       
            adoCmd.ExecuteReader()

            While adoRdr.Read()
                adoRdr("Salary")  =  adoRdr("Salary")   * 0.05
                adoRdr("Surname") =  adoRdr("Surname")
            End While

            CrystalReportViewer1.Zoom(1)
            CrystalReportViewer1.Refresh()

        Catch ex As Exception

        End Try

    End Sub

解决方案

add two lines before refreshing...

cryRpt.setdatasource=dr
crystalreportviewer1.reportsource=cryRpt


这篇关于如何在Crystal Reports中使用更新的datareader的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆