Link to home
Start Free TrialLog in
Avatar of TelDig
TelDigFlag for Canada

asked on

Changing DataSource location for a Stored Procedure with CR XI

Hi,

I have reports (created with Crytal Report XI) using Stored Procedure. If I'm looking at the SQL query done by the report, I see that the database name is "hardcoded" in the string.  These reports will be ran using a C# application and the datasource is overriden to connect to the database/server used by the application.

However, when doing some testing, I noticed that the data displayed in the report does not match with the data displayed in the application. The connection of the report does not seem to have changed when I gave the new connection (using C#).  I did some test and I have no problem when the report was builded using a "command" instead of the stored procedure directly from the list.

It's where I'm completely lost, what should I do next? I can easily change the DataSource location of my report to point to another database, but in the production environment, I'll be using two different database server so I'll have to change the reports twice before they can be used by our customer.  My second option was to change the DataSource for a "Command", but since the fields are linked to an adapter, if I add a new adapter (Querying the same stored procedure with the same parameters / fields) and remove the old one, the fields will be deleted from the report!

Our development environment is Visual Studio 2003 (using C# as stated), SQL Server 2000 and Crystal Report XI. In summary, I need a quick and easy (if possible) way to change my reports to reflect the connection specified by our application.

Thanks for your time.
Avatar of Mike McCracken
Mike McCracken

Is the report saved with data?  CHeck under the FILE menu or in OPTIONS

mlmcc
Avatar of TelDig

ASKER

Hi,

some of them were flagged with the save data. I tested it and it doesn't seem to change the database used.  If I use the CR designer and change the datasource location, it will work fine; but as I have stated, I will use many databases when I'll be in production.

Curiously, we did some changes in our applicaiton and we made the report worked.

We were using the command :
            reportDocument.DataSourceConnections[0].SetConnection(databaseServer, databaseName, true);
to set the new connection and with my stored procedures it didn't work.

Now I browse through all the tables (it should be only my stored procedure) and I change the table location with the database name that I use. Unfortunately, we used that method in the past and it brings other problems; BusinessObjects told us to not use that method. I will do some more testing about that one.

And thanks for the quick answer and the "OPTIONS" hints. I'm guessing since I unchecked it there, it won't be checked by default ?
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Glad i could help

mlmcc