This is a copy of a post off of the Microsoft forums that I didn't want to lose.
I have the problem about change database name and server name runtime...
I use CR for VS.NET 2005 to make a simple report
Use OLEDB for SQL Server and write SQL Statement in COMMAND OBJECT..
(Error will not occur, if I choose link table, not manually write SQL Statement)
I found that i cannot change DBName and ServerName
I receive error when i call function
Report.Database.Table(i).ApplyLogOnInfo(NewLogOnInfo)
--------------------------------------------
Failed to load database information.
Details: The database DLL 'crdb_query.dll' could not be loaded.
Error in File C:\DOCUME~1\anop3\LOCALS~1\Temp\{68D71403-5484-4650-B960-D55DB2523564}.rpt:
Failed to load database information.
---------------------------------------------
Then, I write code in miss password for bring popup, "Select Database" Window, to show
I found that if I write SQL Statement,
The Combo box of ServerName and Database are disable
I can change only userID and Password
Then I found new function in CR For VS2005
Report.SetDatabaseLogon()
It isn't show error but it not work to bring data from new database
By the way, it correct if i change only userID and Password
So, I back to try with VS2003... It is OK....
I don't sure i found it have hotfix for this problem in Crystal Version 10 but not Fix For "Crystal Report for .NET 2005"....
How can I apply the fix?
Please Help me to find out what should i missing and
what should i do
I think it is the critical function because
When i develop i use Develop Server and
I need to change database to Production Server
and it can done in VS2003
==================
Hello,
I tried out what you are doing and reproduced the error. I will track this with our developers.
At this time we don't have a fix or workaround for this.
Keith - Business Objects
==================
Command objects were not supported in VS .NET 2003, so how did you design your VS .NET 2003 report? They were introduced in Crystal Reports 10, so they are new to the Visual Studio releases.
Unfortunately, I suspect that changing the database server name and database name on Command objects may require crdb_query.dll, which we cut from Crystal Reports for VS 2005. I will look into this.
Thanks,
Francis
=============================
OK - I think Ive got it. I was having the same problem as everyone else after updating from vs2003 to vs2005. The same code which worked in 2003 did not work in 2005.
The problem only arises when you run the report on a different database to the one you develop on.
Previously in VS2003, table.Location would report "DATABASE.dbo.NAME" - and it was possible to use this to change the Location, but in vs2005 table.Location only reports back the NAME. See below for a fix.
The problem is in this line:
table.Location = connectionInfo.DatabaseName & ".dbo." & _
table.Location.Substring(table.Location.LastIndexOf(".") + 1)
Change it to:
table.Location = connectionInfo.DatabaseName & ".dbo." & table.Name
This worked for me. Note that id you use
table.Location = connectionInfo.DatabaseName & ".dbo." & table.Location then it does not work.
I cant beleive how bad this is, and that CR/Business Objects have not provided a fix for this.
Adam