Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I work on the c#.net window from application, in that i want to add crystal report.
i know how to add crystal report and data source connection.

But problem is i want to add data source connection relative path (like Data Source=|DataDirectory|Db.mdb or something else) so any computer can run my application without much more settings.
Posted
Updated 24-Sep-13 19:48pm
v2

1 solution

Hi Archit,
I suggest you to provide connection string , query and report parameters at runtime for your report.

--
Thanks

Hello Archit,
You can use
C#
CrystalDecisions.Shared.ConnectionInfo 
class to specify connection string at through your code. You can store these connection parameters in a separate file (App. settings file) and read them in your code from there. simply edit this file when you want to change connection so any computer can run your application. See documentation for this class and use it.
See this method for reference

C#
private void SetConnectionInfo (string table, string server, string database, string user, string password)
        { 
           TableLogOnInfo logOnInfo = new TableLogOnInfo();
           logOnInfo = Report.Database.Tables[table].LogOnInfo;
           ConnectionInfo connectionInfo = new ConnectionInfo ();
           connectionInfo = logOnInfo.ConnectionInfo;

           connectionInfo.DatabaseName = database;
           connectionInfo.ServerName = server;
           connectionInfo.Password = password;
           connectionInfo.UserID = user;
           Report.Database.Tables [table].ApplyLogOnInfo(logOnInfo);
        }



Hope this might be helpful to you.
--
Thanks
 
Share this answer
 
v2
Comments
[no name] 25-Sep-13 6:46am    
ok but how ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900