如何在点击按钮时在vb.net中调用水晶报表。 [英] How to call a crystal report in vb.net on click of button.

查看:78
本文介绍了如何在点击按钮时在vb.net中调用水晶报表。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一份水晶报告,我在菜单上调用该报告,

但现在我想通过单击此表单上的按钮从表单中调用该报告

我怎么打电话?







这是一份显示历史详情的报告。





当我查看视图并点击提交时,它会显示pdf。

I have a crystal report i am calling that report from on menu,
but now i want to call that report from a form on click of a button on this form
How can I call ?



Its a report which shows history details.


When i check view and click on submit it shows me pdf.

推荐答案

在Google上搜索并获取几个解决方案:

Search on google and get several solutions:
Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
        Dim cryRpt As New ReportDocument
        Dim crtableLogoninfos As New TableLogOnInfos
        Dim crtableLogoninfo As New TableLogOnInfo
        Dim crConnectionInfo As New ConnectionInfo
        Dim CrTables As Tables
        Dim CrTable As Table

        cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt")

        With crConnectionInfo
            .ServerName = "YOUR SERVER NAME"
            .DatabaseName = "YOUR DATABASE NAME"
            .UserID = "YOUR DATABASE USERNAME"
            .Password = "YOUR DATABASE PASSWORD"
        End With

        CrTables = cryRpt.Database.Tables
        For Each CrTable In CrTables
            crtableLogoninfo = CrTable.LogOnInfo
            crtableLogoninfo.ConnectionInfo = crConnectionInfo
            CrTable.ApplyLogOnInfo(crtableLogoninfo)
        Next

        CrystalReportViewer1.ReportSource = cryRpt
        CrystalReportViewer1.Refresh()
    End Sub


这篇关于如何在点击按钮时在vb.net中调用水晶报表。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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