Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
How to connect a form to crystal report in C# windows application.

Regards
Balamurugan
Posted

1 solution

Hi try this Code

C#
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

CrystalReportWithImage CRPLI = new CrystalReportWithImage();
            Database crDatabase;
            Tables crTables;
            TableLogOnInfo crTableLogOnInfo;
            ConnectionInfo crConnectionInfo;

            crConnectionInfo = new ConnectionInfo();
            crConnectionInfo.ServerName = IPAddress + "\\SQLEXPRESS";
            crConnectionInfo.DatabaseName = "DbName";
            crConnectionInfo.UserID = "UserID";
            crConnectionInfo.Password = "Password";
            crDatabase = CRPLI.Database;
            crTables = crDatabase.Tables;

            foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
            {
                crTableLogOnInfo = crTable.LogOnInfo;
                crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                crTable.ApplyLogOnInfo(crTableLogOnInfo);
            }
            crystalReportViewer1.ReportSource = CRPLI;
            crystalReportViewer1.Show();
        }
 
Share this answer
 

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