on 10-16-2008 7:15 AM
Hi,
I am trying to use a crystal report in my web application (asp.net 2003 + CR Version 8.5)
I get this error: Exception Details: CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.
I think its because this report has more than one datasource. So how can i Logon for a report which has more than one datasource.
Below is my code
Private Sub GetReportData()
Try
Dim crReportDocument As New ReportDocument
Dim ConnInfo As New ConnectionInfo
With ConnInfo
.ServerName = gbVariables.StrReportServer
.DatabaseName = gbVariables.strReportDBName
.UserID = gbVariables.strUsrName
.Password = gbVariables.strUsrPwd
End With
crReportDocument.Load(gbVariables.strDocPathFolder + "\" + "XYZ.rpt")
Me.CrystalReportViewer1.ParameterFieldInfo.Clear()
Dim ParamFields As ParameterFields = Me.CrystalReportViewer1.ParameterFieldInfo
'Set Month Paramter
Dim GetMonthValues As Int16
GetMonthValues = Session("Month")
Dim Per As New ParameterField
Per.ParameterFieldName = "@Month"
Dim Month_Value As New ParameterDiscreteValue
Month_Value.Value = GetMonthValues
Per.CurrentValues.Add(Month_Value)
ParamFields.Add(Per)
Me.CrystalReportViewer1.ParameterFieldInfo = ParamFields
Me.CrystalReportViewer1.ReportSource = crReportDocument
crReportDocument.SetDatabaseLogon(gbVariables.strUsrName, gbVariables.strUsrPwd, gbVariables.StrReportServer, gbVariables.strReportDBName)
Me.CrystalReportViewer1.RefreshReport()
CrystalReportViewer1.Visible = True
Catch ex As Exception
lblError.Text = ex.Message.ToString
End Try
End Sub
This is how i currently loginto database
crReportDocument.SetDatabaseLogon(gbVariables.strUsrName, gbVariables.strUsrPwd, gbVariables.StrReportServer, gbVariables.strReportDBName)
Thanks to help.
I would recommend looking at this White paper on how to logon to a database:
http://www.businessobjects.com/global/pdf/dev_zone/VS2005_Walkthroughs.pdf
Right now, looking at your code, it's quite convoluted. E.g.; you se the connection info, then load the report, then set it to the viewer, then do setdatabaselogon...
You may also want to see the sample app vbnet_win_dbengine sample app in this download:
https://smpdl.sap-ag.de/~sapidp/012002523100006252822008E/net_win_smpl.exe
Finally, I'd recommend that you search these forums as there are a number of great solutions here also.
Ludek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.