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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any way to change the DB location at runtime???

Status
Not open for further replies.

vbasic

Programmer
Jun 25, 2001
10
US
Hello Everyone,

I am expierencing a very stange Crystal situation, and need someone's help.

I have developed some reports against our development SQL Server database using the OLE DB Provider for SQL Server as the reports' database driver. I then incorporate them into my VB app and call them through the RDC (version 8.5) - all works great.

The problem arises when I want to put these into production, and have them run off the production DB. Shouldn't I simply just have to pass the different DB Name to the SetLogOnInfo method??? Apparently this does not work, because, while the reports stll run, they are showing data from the test DB and not the prod DB.

Is this a Crystal bug??? Are the DB locations hard coded to the actual report file in crystal?? Is there any way to use the OLE DB Driver and dynamically change the location of the DB at runtime from a VB app?

Much thanks in advance.
 
This is probably a very daft question (but sometimes it's the simplest thing that causes a problem in situations like these).
Are the reports saved with data ?
I have an application (written in Delphi) that needs to allow for the user connecting to any given database on any given server.
I make use of syntax like :
CRReport.DiscardSavedData
which forces the discarding of any data saved with the report.
I then make use of the 'SetLogOnInfo' method (passing the server-name, database-name, log-in name and password) and then need to tell the report which tables to use. This is done through the setting of the table locations :
i.e. CRReport.Database.Tables[0].Location := 'DatabaseName.TableName';

Admiteddly this is Delphi code but it might prompt you to find the correct syntax as required.

Hope I've been of some help.
Steve
 
Thank you Steve. I appreciate your response. Actually, in this situation, the reports are not saved with the data.

I see that the issue seems to come from the location property of on the tables object.

if I examine the RDC from within VB, and execute the following code
crRpt.Database.Tables(1).SetLogOnInfo is correctly logging on to the server, but the location property
crRpt.Database.Tables(1).Location

still references the original database. I guess I have to manually change this in my code.
 
I figured it out. You have to use the SetTableLocation method in the VB app.

Thanks for your help.
A
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top