Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i switch database servers in crystal reports?

Status
Not open for further replies.

jomuga

Programmer
Sep 21, 2005
15
UG
I need help on how i can switch between database servers using the same report. My application is developed using VB .Net 2003 Professional and SQL Server 2000.
My users data resides in tables with the same structure but on different servers. When a user logs in he/she selects the server machine on which to log on.
I used the following code but my problem is that the different logins still access the original data (on the machine which i used to design the report) despite the fact that the logon information has changed.
My code is as below:
Dim i As Integer
Dim logonInfo as new TableLogOnInfo()
Dim rptReport as new rptTransactions()
rptReport.Load()

For i = 0 To rptReport.Database.Tables.Count - 1
With logonInfo.ConnectionInfo
.ServerName = txtServerName.Text
.DatabaseName = txtDBName.Text
.UserID = txtUserID.Text
.Password = txtPWord.Text
End With
rptReport.Database.Tables.Item(i).ApplyLogOnInfo(logonInfo)
Next i

I am perplexed as to why the report does not go on to pick data to the server as per the above log on info!
Help needed urgently.




 
Try a subreport - that can make a completely different connection from the main report.

Using subreports at a Detail level is highly inefficient: there will be a separate request to the server from the subreport for each detail line. But I can't see a better way to do it.

I assume there is some entirely sound business reason for not moving the data onto a single machine.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Your code looks like it should work. And I don't think subreports are an answer for your problem.

Do you have "Save Data With Report" turned on? That can cause this type of problem.

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
Gonna check if Save with data is turned on. However, i had got a way; i.e by the use of a typed dataset. I would then use .net to connect and retrieve the data and then set the report datasource to the dataset.
I tried this method and got the results i needed.
Thanks a lot guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top