public void SetDatabase(ReportDocument Rpt)
 {
     CrystalDecisions.CrystalReports.Engine.Database crDatabase;
     CrystalDecisions.CrystalReports.Engine.Tables crTables;
     CrystalDecisions.Shared.TableLogOnInfos MyTableLogOnInfos = new CrystalDecisions.Shared.TableLogOnInfos();
     CrystalDecisions.Shared.TableLogOnInfo MyTableLogOnInfo = new CrystalDecisions.Shared.TableLogOnInfo();
     CrystalDecisions.Shared.ConnectionInfo MyConnectionInfo = new CrystalDecisions.Shared.ConnectionInfo();
     //conStr = Session["Connectionstring"].ToString();
     MyTableLogOnInfo.ConnectionInfo = SetConnectionString(MyConnectionInfo, ConnectionString);
     MyTableLogOnInfos.Add(MyTableLogOnInfo);
     AdminActivityCRViewer.LogOnInfo = MyTableLogOnInfos;
     crDatabase = Rpt.Database;
     crTables = crDatabase.Tables;
     foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
     {
         MyTableLogOnInfo = crTable.LogOnInfo;
         MyTableLogOnInfo.ConnectionInfo = MyConnectionInfo;
         crTable.ApplyLogOnInfo(MyTableLogOnInfo);
     }
     setParameters(Rpt);
 }
        void previewID()
        {
            try
            {
                CrystalDecisions.CrystalReports.Engine.ReportDocument objReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                CrystalDecisions.Shared.TableLogOnInfos crtableLogoninfos = new CrystalDecisions.Shared.TableLogOnInfos();

                CrystalDecisions.Shared.TableLogOnInfo ConInfo = new CrystalDecisions.Shared.TableLogOnInfo();

                CrystalDecisions.Shared.ConnectionInfo crConnectionInfo = new CrystalDecisions.Shared.ConnectionInfo();

                CrystalDecisions.CrystalReports.Engine.Tables CrTables;

                CrystalDecisions.Shared.ParameterValues crParameterValues = new CrystalDecisions.Shared.ParameterValues();

                CrystalDecisions.Shared.ParameterDiscreteValue crParameterDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue();

                //objReport.Load(LoadReport());

                objReport.Load(_path + _reportName_Outside);

                string sUserID = "sa";

                string sPassword = "******";

                string sServerName = "192.168.1.42";

                string sDatabaseName = "HRIS";


                crConnectionInfo.ServerName = sServerName;

                crConnectionInfo.DatabaseName = sDatabaseName;

                crConnectionInfo.UserID = sUserID;

                crConnectionInfo.Password = sPassword;


                CrTables = objReport.Database.Tables;

                foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                {
                    ConInfo = CrTable.LogOnInfo;

                    ConInfo.ConnectionInfo = crConnectionInfo;

                    CrTable.ApplyLogOnInfo(ConInfo);
                }

                reportViewer.ViewerCore.ReportSource = objReport;

                //rekta print
                //objReport.PrintToPrinter(1, true, 0, 0);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }