Wednesday, March 28, 2012

Kishore

Dear all.
I am doing a site using asp.net, and i am providing to users to view reports in the browser. I am using crystal reports 9.0. I am facing some problem when calling crystal reports in asp.net. While developing reports i used one database, now i want to change the database name at runtime. I used the following code as suggested by microsoft and crystal decisions. But i could't get the result. When i was running application the report looking for existed database only. If any body try this before, please help me......Thanks..

Dim crSections As Sections
Dim crSection As Section
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crFieldObject As FieldObject
Dim crTextObject As TextObject
Dim StartVal As Integer
Dim LenVal As Integer

Dim ConnPar As Array = Split(AppSettings("ConnectionString2EISDB"), ";")
ReportDocument.Load(Request.QueryString("Path"))

crConnectionInfo = New ConnectionInfo

With crConnectionInfo
StartVal = InStr(ConnPar(3), "=") + 1
LenVal = Len(ConnPar(3)) - InStr(ConnPar(0), "=") + 1
.DatabaseName = Mid(ConnPar(3), StartVal, LenVal)
StartVal = InStr(ConnPar(2), "=") + 1
LenVal = Len(ConnPar(2)) - InStr(ConnPar(0), "=") + 1
.Password = Mid(ConnPar(2), StartVal, LenVal)
StartVal = InStr(ConnPar(0), "=") + 1
LenVal = Len(ConnPar(0)) - InStr(ConnPar(0), "=") + 1
.ServerName = Mid(ConnPar(0), StartVal, LenVal)
StartVal = InStr(ConnPar(1), "=") + 1
LenVal = Len(ConnPar(1)) - InStr(ConnPar(0), "=") + 1
.UserID = Mid(ConnPar(1), StartVal, LenVal)
End With

crTables = reportDocument.Database.Tables

For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next

CrystalReportViewer1.ReportSource = reportDocument1) This should have been in either the ASP.Net or Crystal Reports forum ;)

2) Code is alot easier to read when placed inside code tags :rolleyes:

3) Double check the contents of your crConnectionInfo in a debugger [you MAY be slightly off on the parse, but I can not confirm this from here]

Other than that, the code looks reasonable...|||<moved thread>

No comments:

Post a Comment