The collection of variables locked for read and write access is not available outside of PostExecute.

  • Hi I was getting the error message while creating the package so can some shade some light on this ,I was using variables read/write in script component and please find my code as below . Thanks in advance 🙂

    ' Microsoft SQL Server Integration Services Script Component

    ' Write scripts using Microsoft Visual Basic 2008.

    ' ScriptMain is the entry point class of the script.

    Imports System

    Imports System.Data

    Imports System.Math

    Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper

    Imports Microsoft.SqlServer.Dts.Runtime.Wrapper

    <Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute> _

    <CLSCompliant(False)> _

    Public Class ScriptMain

    Inherits UserComponent

    Public Overrides Sub PreExecute()

    MyBase.PreExecute()

    '

    ' Add your code here for preprocessing or remove if not needed

    '

    End Sub

    Public Overrides Sub PostExecute()

    MyBase.PostExecute()

    '

    ' Add your code here for postprocessing or remove if not needed

    ' You can set read/write variables here, for example:

    ' Me.Variables.MyIntVar = 100

    '

    End Sub

    Public Overrides Sub CreateNewOutputRows()

    '

    ' Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".

    ' For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".

    '

    With Output0Buffer

    .AddRow()

    If IsDBNull(Variables.VPVIDHost) Then

    Variables.VPVIDHost = ""

    .Host = Variables.VPVIDHost.ToString

    Else

    .Host = Variables.VPVIDHost.ToString

    End If

    If IsDBNull(Variables.VPVIDInstance) Then

    Variables.VPVIDInstance = ""

    .Instance = Variables.VPVIDInstance.ToString

    Else

    .Instance = Variables.VPVIDInstance.ToString

    End If

    If IsDBNull(Variables.VPVIDDBName) Then

    Variables.VPVIDDBName = ""

    .DBName = Variables.VPVIDDBName.ToString

    Else

    .DBName = Variables.VPVIDDBName.ToString

    End If

    If IsDBNull(Variables.VPVIDDBType) Then

    Variables.VPVIDDBType = ""

    .DBType = Variables.VPVIDDBType.ToString

    Else

    .DBType = Variables.VPVIDDBType.ToString

    End If

    If IsDBNull(Variables.VPVIDLoginID) Then

    Variables.VPVIDLoginID = ""

    .Loginid = Variables.VPVIDLoginID.ToString

    Else

    .Loginid = Variables.VPVIDLoginID.ToString

    End If

    If IsDBNull(Variables.VPVIDUserID) Then

    Variables.VPVIDUserID = ""

    .Userid = Variables.VPVIDUserID.ToString

    Else

    .Userid = Variables.VPVIDUserID.ToString

    End If

    If IsDBNull(Variables.VPVIDPrivilege) Then

    Variables.VPVIDPrivilege = ""

    .Privilege = Variables.VPVIDPrivilege.ToString

    Else

    .Privilege = Variables.VPVIDPrivilege.ToString

    End If

    End With

    End Sub

    End Class

  • The main script and the event handlers can't share variables if you open them for read/write through the interface.

    Look into LockForOneRead and LockForOneWrite. My guess is this is where you've gotten jammed up.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • So how would my script be ????

    Thanks in advance

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply