I have writtena crystal reports (Crystal 2008) that uses a command and a view to retreive data. Everything works in Crystal. But when I try to run the report using the web site that I created I get errors.
First I used the following:
Dim impersonationContext As System.Security.Principal.WindowsImpersonationContext
Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity
currentWindowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent
impersonationContext = currentWindowsIdentity.Impersonate()
currentWindowsIdentity.Impersonate()
Dim reportPath As String = Server.MapPath("reports\Q01_P0Jan.rpt")
Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rpt.Load(reportPath)
serverName = rpt.DataSourceConnections.Item(0).ServerName
userID = "donpw"
passWord = "donsl!34"
integratedSecurity = True ' rpt.DataSourceConnections.Item(0).IntegratedSecurity
Dim oCRDb As CrystalDecisions.CrystalReports.Engine.Database = rpt.Database()
Dim oCRTables As CrystalDecisions.CrystalReports.Engine.Tables = oCRDb.Tables()
Dim oCRTable As CrystalDecisions.CrystalReports.Engine.Table
Dim oCRTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
Dim oCRConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo
'oCRConnectionInfo.DatabaseName = dbName
oCRConnectionInfo.ServerName = serverName
oCRConnectionInfo.UserID = userID
oCRConnectionInfo.Password = passWord
oCRConnectionInfo.IntegratedSecurity = integratedSecurity
For Each oCRTable In oCRTables
oCRTableLogonInfo = oCRTable.LogOnInfo()
oCRTableLogonInfo.ConnectionInfo = oCRConnectionInfo
oCRTable.ApplyLogOnInfo(oCRTableLogonInfo)
If (oCRTable.Location.IndexOf(".")) > 0 Then
Response.Write(oCRTable.Location & "<br>")
oCRTable.Location = oCRTable.Location.Substring(oCRTable.Location.LastIndexOf(".") + 1)
Else
oCRTable.Location = oCRTable.Location
End If
Next
oCRTables(0).TestConnectivity()
CrystalReportViewer1.ReportSource = rpt
CrystalReportViewer1.DataBind()
impersonationContext.Undo()
End If
When I run this insode VS2005, everything works. When I publish the site and try to run it, it display "The report you requested requires further information." and ask me for user id and password. When I enter them and click Log on report works.
Then I tried the following code:
Dim impersonationContext As System.Security.Principal.WindowsImpersonationContext
Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity
currentWindowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent
impersonationContext = currentWindowsIdentity.Impersonate()
currentWindowsIdentity.Impersonate()
Dim reportPath As String = Server.MapPath("reports\Q01_P0Jan.rpt")
Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rpt.Load(reportPath)
dbName = rpt.DataSourceConnections.Item(0).DatabaseName
serverName = rpt.DataSourceConnections.Item(0).ServerName
userID = "donpw"
passWord = "donsl!34"
integratedSecurity = True ' rpt.DataSourceConnections.Item(0).IntegratedSecurity
CrystalReportViewer1.ReportSource = reportPath
CrystalReportViewer1.DataBind()
configureCRYSTALREPORT()
Again this works with VS2005. When I publish and run the reports, I get the following error.
"Failed to retrieve data from the database. Failed to retrieve data from the database. Error in File "
Could anyone help me in fixing this. I am 100% sure this is a permission issue, but I cannot point to where. It works fine in VS 2005, but not when I publish it.
Any help is greatly appreciated.