如何通过vb.net代码将参数传递给Crystal报表

Gun*_*ner 2 vb.net crystal-reports

我创建了一个水晶报表(交叉标签)。我没有使用任何数据集,而是使用了Crystal Report中的向导从数据库模式调用过程(给定的提供程序是oracle的Microsoft OLEDB提供程序,此后我给了我的数据库凭据(即模式,用户名,密码),并且选择过程并选择我要在报告中显示的列)。

我需要从前端传递5个参数来生成报告。在查看水晶报表预览时,通过提供参数,报表可以正常工作。

现在,我想从前端(vb.net)传递这5个参数,以在CrystalReportViewer中显示报表。请建议将代码写入aspx.vb文件。(PS:-我确实浏览了其他论坛,并找到了一些代码,但是它们所有人都给出了某些或其他错误,因此请发布一个,以便我可以获取特定于我要求的代码)。

提前致谢..

Gun*_*ner 5

我已经使该报告开始工作了……我写了以下代码:

    Dim RptDocument As New ReportDocument

    RptDocument.Load(Server.MapPath("rpt\Report.rpt"))

    RptDocument.SetParameterValue("param1", Session("param1"))
    RptDocument.SetParameterValue("param2", ddlparam2.SelectedValue)
    RptDocument.SetParameterValue("param3", param3.text)
    RptDocument.SetParameterValue("param4", param4.text)
    RptDocument.SetParameterValue("param5", param5.text)

    'Set login info
    Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo

    Dim myTable As Table
    For Each myTable In RptDocument.Database.Tables
        myLogin = myTable.LogOnInfo
        myLogin.ConnectionInfo.ServerName = "server name"
        myLogin.ConnectionInfo.DatabaseName = ""
        myLogin.ConnectionInfo.UserID = "userid"
        myLogin.ConnectionInfo.Password = "pwd"
        myTable.ApplyLogOnInfo(myLogin)
        myTable.Location = myTable.Location

    CrystalReportViewer1.ReportSource = RptDocument
Run Code Online (Sandbox Code Playgroud)

创建了一个系统DNS,并且必须添加Oracle.DataAccess.dll引用和一个类文件(功能与connectooracle.vb类文件中的功能相同,但名称不同),还在global.asax中设置了一个连接以引用该类连接并Imports Oracle.DataAccess.Client改为使用 的Imports System.Data.OracleClient(以避免歧义)...

这样使它工作,并且可能还有其他解决方案.. :)

(For ref:- Adding  myLogin.ConnectionInfo.IntegratedSecurity = True  gave me this error--
Logon failed. Error in File C:\DOCUME~1\Username\LOCALS~1\Temp\Report {1AG3DD86-141D-43YA-B6A2-AEDF3459AE49}.rpt: Unable to connect: incorrect log on parameters.)
Run Code Online (Sandbox Code Playgroud)