Crystal reports
Question posted by: OuTCasT
(Familiar Sight)
on
June 30th, 2008 10:55 AM
i have a payroll program that can start new companies, a company has its own database. they will always be the same tables etc inside all the databases/companies.
now i have done a report in crystal reports. now i want to use jst that report for all the companies that will be created.
I have changed the servername and databasename at runtime but it still brings back the information from the company that i designed the report on....
is there something that im missing.
Code: ( text )
Dim report As New ReportDocument Dim connection As IConnectionInfo Dim oldServerName As String = "" Dim oldDatabaseName As String = "" Dim newServerName As String = TextBox1.Text Dim newDatabaseName As String = "dude" Dim UserID As String = "" Dim Password As String = "" report.Load("C:\report2.rpt") CrystalReportViewer1.ReportSource = report 'Change the server name and database in main report For Each connection In report.DataSourceConnections If (String.Compare(connection.ServerName, oldServerName, True) = 0 _ And String.Compare(connection.DatabaseName, oldDatabaseName, True) = 0) Then 'SetConnection can also be used to set new logon and new database table report.DataSourceConnections(oldDatabaseName, oldDatabaseName).SetConnection(newServerName, newDatabaseName, UserID, Password) End If Next 'Change the server name and database subreports Dim subreport As ReportDocument For Each subreport In report.Subreports For Each connection In subreport.DataSourceConnections If (String.Compare(connection.ServerName, oldServerName, True) = 0 _ And String.Compare(connection.DatabaseName, oldDatabaseName, True) = 0) Then subreport.DataSourceConnections(oldServerName, oldDatabaseName).SetConnection(newServerName, newDatabaseName, UserID, Password) End If Next Next
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
|
|
July 21st, 2008 10:56 AM
# 2
|
Re: Crystal reports
I did something like this:
private report2 As ReportDocument
in load:
report2 = New ReportDocument
report2.Load("report1.rpt")
report2.SetDatabaseLogon(UserName, UserPassword)
report2.Database.Tables(0).SetDataSource(datatable 1)
report2.Refresh()
cristalViewer1.ReportSource = report2
Not the answer you were looking for? Post your question . . .
183,969 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).
|
|
|
Latest Articles: Read & Comment
Top Microsoft SQL Server Contributors
|