Thursday 31 January 2013

Cristal Report In Dyanamically Method


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using Swash.Objects;
using System.Data;
using System.Data.SqlClient;



  private void frmReportViewer_Load(object sender, EventArgs e)
        {

            TAGGING_CommonVariable objVar = new TAGGING_CommonVariable();
            objVar.servername = @"Satya\Linku";
            objVar.DatabaseName = "XXXXXX";
            objVar.username = "aaaa";
            objVar.password = "ddddd";

            if (reportFlag == 0)//IssueToQualityControl
            {
                crReportIssueToQC objCr = new crReportIssueToQC();
                CrystalDecisions.Shared.TableLogOnInfo tliCurrent = default(CrystalDecisions.Shared.TableLogOnInfo);
                try
                {
                    foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in objCr.Database.Tables)
                    {
                        tliCurrent = tbCurrent.LogOnInfo;
                        var _with1 = tliCurrent.ConnectionInfo;
                        _with1.ServerName = objVar.servername;
                        _with1.DatabaseName = objVar.DatabaseName;
                        _with1.UserID = objVar.username;
                        _with1.Password = objVar.password;
                        _with1.IntegratedSecurity = false;
                        tbCurrent.ApplyLogOnInfo(tliCurrent);
                    }

                    this.crystalReportViewerAll.ReportSource = objCr;
                    objCr.SetParameterValue(0, paramvalue);
                    //objCr.SetParameterValue(1, paramvalueId);
                    crystalReportViewerAll.Show();
                }
                catch
                {

                }
            }

No comments:

Post a Comment