Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

asp.net error

  • 12-04-2010 11:23AM
    #1
    Closed Accounts Posts: 1,759 ✭✭✭


    Hi,

    Executing an SSIS package within .net, which has a parameter.

    I am getting an error, you're help would be appreciated.
    "Error trying to write to a read-only variable, "CancelEvent""

    The code I have is just this.

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim app As Application = New Application()
    ' Load the packages.
    Dim p1 As Package = app.LoadFromSqlServer("ImportJobPKG", "myserver", Nothing, Nothing, Nothing)

    p1.Variables(
    0).Value = FileUpload1.PostedFile.FileName
    p1.Execute()
     
    End Sub


Comments

  • Closed Accounts Posts: 1,759 ✭✭✭Dr.Silly


    Dr.Silly wrote: »
    Hi,

    Executing an SSIS package within .net, which has a parameter.

    I am getting an error, you're help would be appreciated.
    "Error trying to write to a read-only variable, "CancelEvent""

    The code I have is just this.

    ProtectedSub Button1_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles Button1.Click
    Dim app AsApplication = NewApplication()
    ' Load the packages.
    Dim p1 AsPackage = app.LoadFromSqlServer("ImportJobPKG", "myserver", Nothing, Nothing, Nothing)

    p1.Variables(
    0).Value = FileUpload1.PostedFile.FileName
    p1.Execute()
     
    EndSub

    the error is on this line btw.
    p1.Variables(0).Value = FileUpload1.PostedFile.FileName

    thanks


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Can you post the error details?


  • Closed Accounts Posts: 1,759 ✭✭✭Dr.Silly


    Evil Phil wrote: »
    Can you post the error details?

    Thanks Evil Phil. Here they are


  • Closed Accounts Posts: 1,759 ✭✭✭Dr.Silly


    got it sorted, code below in case anyone else has same issue.


    Dim app As Application = New Application()
    ' Load the packages.
    Dim p1 As Package = app.LoadFromSqlServer("Package", "myServer", Nothing, Nothing, Nothing)
    Dim vars As Variables
    vars = p1.Variables
    vars(
    "myPath").ReadOnly = False
    p1.VariableDispenser.LockOneForWrite("myPath", vars)
    vars(
    "myPath").Value = FileUpload1.PostedFile.FileName
    vars.Unlock()
    p1.Execute()


Advertisement