1

我创建水晶报告,要求用户输入...我用户参数字段询问开始日期和结束日期以获取报告...

一切顺利,直到用户提交他们的开始和结束日期......

水晶报告不断询问数据库的密码,除非我把它写在代码中......这里是我的代码

Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
    If DropDownList1.SelectedValue = "Jam Masuk" Then
        Dim reportdocument As New ReportDocument()
        reportdocument.Load("D:\MIS Project\Master Project MIS\BSTM\Security\ReportTamuMasuk.rpt")
        reportdocument.SetDatabaseLogon("sa", "P@ssw0rd")
        reportdocument.SetParameterValue("Akhir Jam Masuk", Label2.Text)
        CrystalReportViewer1.ReportSource = reportdocument
        CrystalReportViewer1.Visible = True
    ElseIf DropDownList1.SelectedValue = "Jam Keluar" Then
        Dim reportdocument As New ReportDocument()
        reportdocument.Load(Server.MapPath("ReportTamuKeluar.rpt"))
        reportdocument.SetDatabaseLogon("sa", "P@ssw0rd")
        reportdocument.SetParameterValue("Akhir Jam Keluar", Label2.Text)
        CrystalReportViewer1.ReportSource = reportdocument
        CrystalReportViewer1.Visible = True
    Else
        CrystalReportViewer1.Visible = False
    End If
End Sub
4

2 回答 2

1

我有同样的问题,但我找到了一个简单的解决方案。你只需要用数据表替换数据集,它就可以正常工作了..

于 2014-02-14T04:07:44.170 回答
0

我使用此代码进行 oracle 连接,并使用 CRAXDRT.dll 在 c# 中创建报告,也许它可以帮助您:

CRAXDRT.DatabaseTable T;
        for (int i = 1; i <= report1.Database.Tables.Count; i++)
        {
            T = (CRAXDRT.DatabaseTable)report1.Database.Tables[i];
            CRAXDRT.ConnectionProperties cps = T.ConnectionProperties;
            CRAXDRT.ConnectionProperty cp =
                (CRAXDRT.ConnectionProperty)cps["User ID"];
            cp.Value = "Username";//DB.Username;

            cp = (CRAXDRT.ConnectionProperty)cps["Password"];
            cp.Value = "Password";// DB.Password;

            cp = (CRAXDRT.ConnectionProperty)cps["Data Source"];
            cp.Value = "DataSource";//DB.DataSource;

            T.SetLogOnInfo("DataSource", "", "Username", "Password");
        }
于 2013-10-29T10:40:04.087 回答