Crystal Reports \SF Connection Info


Author
Message
Michael Reese
Michael Reese
StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)
Group: StrataFrame Users
Posts: 235, Visits: 1.6K
Can anyone help me with establishing a connection to SF at runtime. I keep getting an error using the Crystal "ConnectionInfo" with the SF "ConnectionString"

Thanks Much.

Sample code

******************************************************

Private Sub ConfigureCrystalReports()

Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()

myConnectionInfo.DatabaseName = "MYDB"

myConnectionInfo.UserID = "Test"

myConnectionInfo.Password = "1234"

myConnectionInfo.ServerName = "MYServer"

northwindCustomersReport = New ReportDocument()

Dim reportPath As String = Application.StartupPath & "\" & "SubjectReport.rpt"

northwindCustomersReport.Load(reportPath)

myCrystalReportViewer.ReportSource = northwindCustomersReport

SetDBLogonForReport(myConnectionInfo, northwindCustomersReport)

End Sub

Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo, ByVal myReportDocument As ReportDocument)

Dim myTables As Tables = myReportdocument.Database.Tables

For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables

Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo

myTableLogonInfo.ConnectionInfo = myConnectionInfo

myTable.ApplyLogOnInfo(myTableLogonInfo)

Next

End Sub

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
What's the error you're getting?  It might be that you have to build the connection info like you are doing in your example, and to parse out the pieces of the connection string, you can use SqlConnectionStringBuilder.

Dim builder As New SqlConnectionStringBuilder(DataBasics.DataSources(String.Empty).ConnectionString)

The builder then has all the properties like DataSource, InitialCatalog, Username, Password, WindowsAuth, etc.

Michael Reese
Michael Reese
StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)
Group: StrataFrame Users
Posts: 235, Visits: 1.6K
Hey Ben,

I am getting a connection error,

Failed to open the connection.
Failed to open the connection.
C:\DOCUME~1\MICHAEL\LOCALS~1\Temp\rptSingleSubject

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
It sounds like your connection is not correct.  Were you sure to include the data base (Initial Catalog)?  If you ToString the SqlConnectionStringBuilder what does your connection string look like?  More than likely you are getting a valid error.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search