Print Page | Close Window

Crystal Reports and Deployment Package (publish)

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=2972
Printed Date: 04 May 2025 at 8:26am


Topic: Crystal Reports and Deployment Package (publish)
Posted By: VBProEd
Subject: Crystal Reports and Deployment Package (publish)
Date Posted: 18 Apr 2008 at 9:56am
If I am re-iterating an old topic then please point me to an already existing thread.
 
I am developing a VB.Net 2005 application with Crystal Reports viewer embedded in a window for reporting in the application. I have included the pre-requisites (Crystal Reports for .Net Framework 2.0) and published the package.  The install properly recognizes that .Net 2.0 and Crystal Reports need to be installed on the target workstation before the actual application install so all of that works fine.  However, when executing the application and attempting to show a report on the viewer, the application just hangs.  The Crystal Report Viewer works fine on my XP development box without a hitch. 
 
Did I miss any other pre-requisites not mentioned above?  I perused the Crystal Reports .Net Programming book written by Brian but it references VS2003 and not VS2005 so there must be some suttle differences.  Perhaps a license key or something?  No error dialog windows appeared but I didn't let it time out either.



Replies:
Posted By: VBProEd
Date Posted: 19 Apr 2008 at 3:21pm

I found this website URL with decent instructions from Business Objects: http://support.businessobjects.com/downloads/runtime.asp - http://support.businessobjects.com/downloads/runtime.asp

I will need to test everything on an XP Workstation next week.  When I rebuilt the Release package, a plethora of .dll's were included in the Setup.exe file.
 
Results: After installation of the merge modules and a successful Release build/publish, I am still having the same problem with application hanging.  Now putting in msgbox displays to try and isolate problem.


Posted By: VBProEd
Date Posted: 22 Apr 2008 at 8:27am

Ok, outside the development environment, it's hanging up on either ApplyLogOnInfo or the Location setting.  Function ExtractServerDatabaseNames is returning the correct Server and Database names.  Below is my code used for modifying the Server/Databasename and I use Stored Procedures for the CrystalReportViewer data.  Anyone have a suggestion?

Public Sub SetDatabaseLogonConnection(ByRef MyReport As Object, ByVal MyConnectionString As String)

'During runtime, the Production server/database needs to be updated from the development server/database.

'The purpose of this sub is to dynamically update the server/database at runtime.

Dim MyServerName As String = String.Empty

Dim MyDatabaseName As String = String.Empty

Dim MyTable As CrystalDecisions.CrystalReports.Engine.Table

Dim MyConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo

Dim MyLogonInfo As New CrystalDecisions.Shared.TableLogOnInfo

'Get the Server and Databasename from the project connection string

If ExtractServerDatabaseNames(MyConnectionString, MyServerName, MyDatabaseName) Then

'Update the Server/Databasename in the report

For Each MyTable In MyReport.Database.Tables

MyLogonInfo = MyTable.LogOnInfo

'We need the userid/password from MyConnectionInfo initialized before modifying the Server/Databasename

MyLogonInfo.ConnectionInfo = MyConnectionInfo

'Reset the target Server and Database names

If MyServerName <> String.Empty Then

'If you have a need for a Secure Datasource, you would need to update the userid/password here

'BEFORE calling ApplyLogOnInfo

MyLogonInfo.ConnectionInfo.ServerName = MyServerName

MyLogonInfo.ConnectionInfo.DatabaseName = MyDatabaseName

MyLogonInfo.ConnectionInfo.IntegratedSecurity = True

End If

MDIParent1.ToolStripStatusLabel.Text = "Applying Crystal Reports connection to database " & MyServerName & "/" & MyDatabaseName & "...Please wait"

MDIParent1.Update()

MyTable.ApplyLogOnInfo(MyLogonInfo)

If MyServerName <> String.Empty Then

MyTable.Location = MyTable.Location.Substring(MyTable.Location.LastIndexOf(".") + 1)

End If

Next

End If

End Sub

Public Function ExtractServerDatabaseNames(ByVal MyConnectionString As String, ByRef MyServerName As String, ByRef MyDatabaseName As String) As Boolean

'Extract the Server/Databasename from the project connection string

Const DataSource As String = "Data Source="

Const InitialCatalog As String = "Initial Catalog="

Dim Results() As String

Try

Results = Regex.Split(MyConnectionString, ";", RegexOptions.Multiline)

Catch exp As Exception

MsgBox("An error was encountered when attempting to parse the Connection String. Check to insure that the connection exists." & vbCrLf & exp.Message, _

MsgBoxStyle.Critical, Me.Text)

Return False

End Try

' To be split a string array of at least two elements must be created.

If Results.Length > 1 Then

For Each s As String In Results

If InStr(1, s, DataSource) Then

MyServerName = Trim(Mid(s, Len(DataSource) + 1, Len(s) - Len(DataSource)))

ElseIf InStr(1, s, InitialCatalog) Then

MyDatabaseName = Trim(Mid(s, Len(InitialCatalog) + 1, Len(s) - Len(InitialCatalog)))

End If

Next

End If

Return True

End Function




Print Page | Close Window