Dynamic Database Linking - CR XI
Hi bros..
I am using CR XI. I designed a report and added test SQL Server 2000 database to view and test the report results. Now in my program, I have to connect to the database using a dynamic connection string.
e.g in deign I am using testdatabase. Once design is done, I have to conenct to the ProductionDatabase in my VB code.
Thanks for your urgent reply
Re: Dynamic Database Linking - CR XI
Re: Dynamic Database Linking - CR XI
Sorry but its for Crystal 9. I need for XI.
I know I have to use Creport.LogOnServer method but its not working. It does not give me any error but displays the data of design time database.
Since all the tables and links are desinged, I don't want to delete all and redesign in my code. It sounds stupid.
I should be able to just logon to the desired server and thats it.
Right?
Re: Dynamic Database Linking - CR XI
Quote:
Originally Posted by tansarbh
I know I have to use Creport.LogOnServer method but its not working. It does not give me any error but displays the data of design time database.
Check that you're not saving data with the report. When designing a report, by default it saves the data with the report, which means that everytime you run the report you get the same original data.
Open your report in Crystal and have a look under the File menu and make sure that Save Data with Report is not checked.
Re: Dynamic Database Linking - CR XI
Quote:
Originally Posted by pnish
Check that you're not saving data with the report. When designing a report, by default it saves the data with the report, which means that everytime you run the report you get the same original data.
Open your report in Crystal and have a look under the File menu and make sure that Save Data with Report is not checked.
Yeah, I am aware of that and its not checked. Right now, the only solution is to create two ODBC connections and change it every time I have to switch the databse....which sounds non professional....
Thanks.
Re: Dynamic Database Linking - CR XI
I would try the solution posted in the other tread anyway (even if it is for version 9). I don't think they have changed the connection properties from 9 to 11.
Re: Dynamic Database Linking - CR XI
Hi, I am having the same problem. VB6, CR11, SQL 2000. When I change the database, data is still pointing to the 1st db and Save Data with Report is not checked.
Dim crCrystal As New craxdrt.Application
Dim crReport As craxdrt.Report
Set crReport = crCrystal.OpenReport(g_CRReportPath)
crReport.DiscardSavedData
With crReport.Database
For i = 1 To .Tables.Count
.Tables(i).SetLogOnInfo g_Server, g_Database, g_User, g_Pwd
Next
End With
CRViewer.ReportSource = crReport
CRViewer.ViewReport
In fact, in CR11, if I open the report, do Verify Database and change the db there, it also doesn't work because when I look at the properties in Set Database Location, the connection properties show Initial Catalog pointing at the new db but the table's properties show that the Catalog still pointing to the old db.
In my code, I tried the code suggestion above ...Item("Database Name") = g_database but I get the error Subscript out of range.
Please help. Thanks.