Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Report.ReportCatProducts rcp = new Report.ReportCatProducts();
rcp.SetDatabaseLogon("pc1", "12", "Server", "MnStores", false);
rcp.SetParameterValue("@catId",this.dataGridView1.CurrentRow.Cells[0].Value.ToString());
Report.FormCatProducts2 fcp2 = new Report.FormCatProducts2();
fcp2.crystalReportViewer1.ReportSource = rcp;
fcp2.ShowDialog();
Posted

1 solution

I think you will have to provide logon info for all the tables involved within your report source. Please see code below which might help you.
Note: The connection security information must be supplied in a different way rather than as specified below for security purpose (Passwords and server info should not be typed directly as shown in the code below - I am only using it to simplify things). Again, if you want to specify parameters to the source, you can as you are doing it.

C#
ReportDocument report = new ReportDocument();
                    TableLogOnInfo logoninfo = new TableLogOnInfo();
                    ConnectionInfo connectioninfo = new ConnectionInfo();
                    Tables tables;

                    connectioninfo.ServerName = "<Your Database Server Name>"
                    connectioninfo.DatabaseName = "<Your Database Name>";
                    connectioninfo.UserID = "<Your Database User>";
                    connectioninfo.Password = "<Your Database User Password";
                    
	      string ReportPath = Server.MapPath("TempReport.rpt");

                    report.Load(ReportPath);
                    tables = report.Database.Tables;

                    foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
                    {
                        logoninfo = table.LogOnInfo;
                        logoninfo.ConnectionInfo = connectioninfo;
                        table.ApplyLogOnInfo(logoninfo);
                    }

                    this.crysreportviewer.ReportSource = report;
                    crysreportviewer.RefreshReport();
 
Share this answer
 
v2
Comments
Member 11280947 30-Mar-15 15:39pm    
1-this First code

ReportDocument report = new ReportDocument();
TableLogOnInfo logoninfo = new TableLogOnInfo();
ConnectionInfo connectioninfo = new ConnectionInfo();
Tables tables;

connectioninfo.ServerName = "<your database="" server="" name="">"
connectioninfo.DatabaseName = "<your database="" name="">";
connectioninfo.UserID = "<your database="" user="">";
connectioninfo.Password = "
Nayan Ambaliya 30-Mar-15 20:14pm    
what are you trying to say.. ?
Member 11280947 31-Mar-15 15:53pm    
how can use the store procedure

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