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

Crystal Reports 2011, table.ApplyLogOnInfo has no effect

Status
Not open for further replies.

kristofdielis

Programmer
Sep 1, 2011
25
Hi,

I'm writing a 'general purpose' back-end, that needs to provide basic operations, to load a Crystal Reports report.

Using the connection string I get from the client app (a test program, at the moment), I build a ConnectionInfo object and apply it to the table(s) of the selected report (+ sub reports):

Code:
                    CRS.TableLogOnInfo tableLogOnInfo = table.LogOnInfo;

                    tableLogOnInfo.ConnectionInfo.ServerName = connectionInfo.ServerName;
                    tableLogOnInfo.ConnectionInfo.DatabaseName = connectionInfo.DatabaseName;
                    tableLogOnInfo.ConnectionInfo.UserID = connectionInfo.UserID;
                    tableLogOnInfo.ConnectionInfo.Password = connectionInfo.Password;

                    table.ApplyLogOnInfo(tableLogOnInfo);

If I halt the debugger on the last line, table contains the correct information. Once I execute the ApplyLogOnInfo, it seems to have restored the original connection, provided in the report itself.

Any idea why ApplyLogOnInfo doesn't accept my changes?

Thx.
 
I find it's much easier to push data to the report rather than have the report pull data from a database. Use a datatable or dataset as the data source for the report.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Sadly I have no choice, the back-end is essentially an upgrade of existing functionality, with existing reports that can not be changed, that's just not going to happen.

So, I have to make it work the way it is.
 
What is the report connection type? Your code may work for OLE DB connections but will not work for ODBC connections.

Report automation for Crystal reports and SSRS
 
All data is fetched within the report(s), I only (try to) set the database credentials and the parameters.

Essentially, the code works, that has been proven for many years now, except, it just doesn't anymore on my own pc, with the new CR 2011 version (= 13).

That seems to suggest that CR no longer supports ApplyLogOnInfo, at least the way it used to.
 
Do you really need to change server and database name ?
If they are the same check if your code will work when you set just the values for user and password.
You will be able to change the server and database too , but setting ConnectionInfo properties will not work for all crystal versions and all connection types.

Report automation for Crystal reports and SSRS
 
@RTag
I would hope you don't develop against the production database. Having a local copy of the db schema and a subset of data makes for a much better development experience. then it should just be a matter of changing the connection string.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
No, I am not developing against production database :). Generally it is not a good idea to work on you machine too.
Having separate test and real (production) word is probably the best scenario. When the report is ready in test world deploy it to real world and change server/database name to avoid doing that each time when you run it (this will work if you develop on your machine too). If the report is used with more than one database or server then connection should be set in runtime, but the code may be different for different connection types and crystal versions and may require update when crystal reports is upgraded.

Report automation for Crystal reports and SSRS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top