Monday, November 26, 2012

SSIS Package using SQL Server Business Intellegence development Student

Is is used to transfer data in tables of two diffrent database

1.Add Data Flow Task

2.On the Data flow
    A).  Add OLE DB Source:double click and add database source connection string and choose table which need to transfer.
   B).Add OLE DB Destincation :double click and add database destination connection string and choose table in which data need to import.

now just run the application and Both source and destination OLE DB should be green heighlighted.It is a symbol of sucess or if it is showing red the there is error in package.

===============================================

Code for calling package in asp.net using c#



using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.SqlServer.Server;
using Microsoft.SqlServer.Dts;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using Microsoft.SqlServer.Dts.Tasks.ScriptTask;
namespace CallPackage
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnexecute_Click(object sender, EventArgs e)
        {
            try
            {
                Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
               Microsoft.SqlServer.Dts.Runtime.Package package = null;
                package =(Microsoft.SqlServer.Dts.Runtime.Package) app.LoadPackage(@"C:\Ajay\Package.dtsx",null,true);
                Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute();

                if (results == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure)
                {
                    foreach (Microsoft.SqlServer.Dts.Runtime.DtsError local_DtsError in package.Errors)
                    {

                        Console.WriteLine("Package Execution results: {0}", local_DtsError.Description.ToString());
                        Console.WriteLine();
                    }
                }

            }
            catch (Exception ex)
            {
                string SS = ex.Message;
            }
        }
    }
}


    

1 comment:

  1. Ajay,

    Does .dtsx file has to be in the same server ? i need to keep .dtsx file in Network share folder, is it possible ?
    -Keshav

    ReplyDelete