Welcome to Sign in | Help

Re: SSIS Quick Start

  •  12-01-2006, 8:25 PM

    Re: SSIS Quick Start

    Intr-o oarecare masura, mi-ai "transmis" confuzia...ce are dbase-ul cu vreun "server sql"? Deci, sperand ca te-am inteles, merg mai departe...

    Nu am lucrat niciodata cu dbase, deci cu un exemplu "fix pentru tine" nu te pot ajuta, din pacate...

    Din cate imi dau seama, problema ta ar fi referirea elementelor pachetului SSIS din script task. Poti face asta prin intermediul "Dts object". De exemplu, definesti un "connection manager" astfel:

    Dim conmgr As ConnectionManager = Dts.Connections("nume_connection_manager")

     Conexiunea propriu-zisa va fi:

    conn = CType(conmgr.AcquireConnection(Nothing), SqlConnection) 

    "Dts object" este descris destul de in amanunt in BOL (da o cautare dupa "Dts object")

    Uite si cam cum lucrezi cu o baza SQL:

     Public Sub Main()
            Dim conmgr As ConnectionManager = Dts.Connections("nume_connection_manager")
            Dim r As SqlDataReader
            Dim conn1 As SqlConnection, conn2 As SqlConnection, conn3 As SqlConnection
            Dim s As String, p As String
            Dim arr As String()
            conn1 = CType(conmgr.AcquireConnection(Nothing), SqlConnection)
            Try
                Using (conn1)
                    Dim cmd1 As New SqlCommand("SELECT DISTINCT col1 FROM Tab1 WHERE col1 IS NOT NULL", conn1)
                    Dim cmd2 As New SqlCommand("SELECT DISTINCT col2 FROM  Tab2 WHERE col2 IS NOT NULL", conn1)
                    Using (cmd1)
                        r = cmd1.ExecuteReader
                        Using (r)
                            While r.Read
                               ...your code here...

                           End While
                        End Using
                    End Using
                    Using (cmd2)
                        r = cmd2.ExecuteReader
                        Using (r)
                            While r.Read
                               ...your code here...
                            End While
                        End Using
                    End Using
                End Using
            Catch
                Dts.Events.FireError(0, "Script Task", "Unexpected error occured", String.Empty, 0)
            End Try
            Dts.TaskResult = Dts.Results.Success
        End Sub

     

View Complete Thread
Powered by Community Server (Commercial Edition), by Telligent Systems