我创建水晶报告,询问用户输入... i用户参数字段,询问开始日期和结束日期以获取报告...
一切顺利,直到用户提交他们的开始和结束日期......
水晶报告不断询问数据库的密码,除非我把它写在代码中......这里是我的代码
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
答案 0 :(得分:1)
我有同样的问题,但我找到了一个简单的解决方案。你只需要用数据表替换数据集,它就能正常工作..
答案 1 :(得分: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");
}