This was a fun problem to solve :). The issue that I came across with this
error was that the database connection/password needed to be set for each
table in the main report as well as any subreports. If there were tables
with the connection information not set, the database login would be
displayed for each table with the missing information.
The code that I used to correct this problem is as follows:
If File.Exists(str Report) Then
Dim crlogInfo As New CrystalDecision s.Shared.TableL ogOnInfo()
Dim crConnInfo As New CrystalDecision s.Shared.Connec tionInfo()
Dim intCount As Integer, intRecCount As Integer
Dim strTmp As String
m_crdocReport = New ReportDocument( )
m_crdocReport.L oad(strReport,
CrystalDecision s.Shared.OpenRe portMethod.Open ReportByTempCop y)
'Set database for main tables
With crConnInfo
..ServerName = ""
..UserID = ""
..DatabaseName = strDataBasePath
..Password = "mypassword "
End With
crlogInfo.Conne ctionInfo = crConnInfo
intRecCount = m_crdocReport.D atabase.Tables. Count - 1
For intCount = 0 To intRecCount
With m_crdocReport.D atabase.Tables( intCount)
..Location = strDataBasePath
..ApplyLogOnInf o(crlogInfo)
strTmp &= .Name & " - " & .Location & " : " &
..LogOnInfo.Con nectionInfo.Pas sword & " : " &
crlogInfo.Conne ctionInfo.Passw ord & vbCrLf
End With
Next
'MsgBox(strTmp)
strTmp = ""
'Set database for any subreports
Dim crSection As Section
Dim crObject As ReportObject
Dim crSubReport As SubreportObject
Dim astrSubReports( ) As String
Dim intSubReports As Integer = -1, intSubReportCou nt As Integer
Dim crSubReportDocu ment As New ReportDocument( )
For Each crSection In m_crdocReport.R eportDefinition .Sections
For Each crObject In crSection.Repor tObjects
If crObject.Kind = ReportObjectKin d.SubreportObje ct Then
crSubReport = CType(crObject, SubreportObject )
intSubReports += 1
ReDim Preserve astrSubReports( intSubReports)
astrSubReports( intSubReports) = crSubReport.Sub reportName
End If
Next
Next
For intSubReportCou nt = 0 To intSubReports
crSubReportDocu ment =
m_crdocReport.O penSubreport(as trSubReports(in tSubReportCount ))
intRecCount = crSubReportDocu ment.Database.T ables.Count - 1
For intCount = 0 To intRecCount
With crSubReportDocu ment.Database.T ables(intCount)
..Location = strDataBasePath
..ApplyLogOnInf o(crlogInfo)
strTmp &= .Name & " - " & .Location & " : " &
..LogOnInfo.Con nectionInfo.Pas sword & " : " &
crlogInfo.Conne ctionInfo.Passw ord & vbCrLf
End With
Next
'MsgBox(strTmp)
strTmp = ""
Next
Jody
"Mithun Verma" <mi*****@MAQSof tware.com> wrote in message
news:Oi******** *****@tk2msftng p13.phx.gbl...
Hello All,
I have a Windows application that uses Crystal Reports 9 (bundled Version)
developed using VS.NET 2003 on a windows server 2003 m/c.
The application has to be deployed on the client machine that has Windows
XP installed. Before deploying we make sure that .NET framework 1.1 is
installed on the XP machine. In the setup project, for support for Crystal
Reports, we have added the following merge modules:
1)Crystal_Manag ed2003.msm
2) Crystal_Databas e_Access2003.ms m
3)Crystal_Datab ase_Access2003_ enu.msm
4)Crystal_RegWi z2003.msm
5)VC_User_CRT71 _RTL_X86.msm
6)VC_User_STL71 _RTL_X86.msm
The problem we are facing is like this: Whenever the user tries to pull up
the reports, a database logon screen pops up for the report. I am unable
to figure out as to why this is happening only for Crystal Reports. All the
other functionality in the application is working fine without having to
specify the database connection information interactively. The database
server is not in the same network as this Client WinXP machine. We specify
the IP address of the DB server in the DB connection string. Could this be
a problem?
If someone has faced this problem earlier or has any solution to this
problem, do let me know. I need to resolve this problem ASAP.
Thanks in advance
Mithun