Showing posts with label inside. Show all posts
Showing posts with label inside. Show all posts

Friday, February 24, 2012

Accessing varibles inside the ScriptTask

Hi All,

In one of my ScriptTasks, I instantiate FileSystemWatcher class and set events for it. This has been done inside the Main() method. I can access all the varibles declared in the SSIS package inside the Main() method (by using Dts.Variables("").Value) but none can be accessed inside the event methods. One possible reason for this can be, events might be running in different threads.

Now my question is, How the varibles can be accessed inside the event methods.

Hope someone can give me a solution. Appricate all your solutions.
Thanks

Hi,

You might want to try using Daniel Read's method of accessing variables here:

http://www.developerdotstar.com/community/node/512

If that doesn't work, then it must be a thread-locking problem, although I can't see how that could really happen.

HTH|||

hi,

How odd, I've tried this snippet of code and it works fine:

Public Sub Main()

uno()

Dts.TaskResult = Dts.Results.Success

End Sub

Public Function uno()

MsgBox(Dts.Variables("RutaFicheroCarga").Value)

End Function

|||

Hi,

I tried the Daniel's method but it didn't work for me. The actual code looks like below.... to show you the exact problem.

Public Sub Main()
Dim watcher As New FileSystemWatcher()
......
......
AddHandler watcher.Created, AddressOf OnChanged
......
......
Dts.TaskResult = Dts.Results.Success
End Sub

Private Sub OnChanged(ByVal source As Object, ByVal e As FileSystemEventArgs)
Try
MsgBox(Dts.Variables("MyVariable").Value.ToString()) ' this gives the error "Object reference not set to an instance of an object"
Catch ex As Exception
MsgBox(ex.Message.ToString())
End Try
End Sub

Looking forward to seeeing a solution for this.

Thanks

|||

SL Coder wrote:

Hi,

I tried the Daniel's method but it didn't work for me. The actual code looks like below.... to show you the exact problem.

Public Sub Main()
Dim watcher As New FileSystemWatcher()
......
......
AddHandler watcher.Created, AddressOf OnChanged
......
......
Dts.TaskResult = Dts.Results.Success
End Sub

Private Sub OnChanged(ByVal source As Object, ByVal e As FileSystemEventArgs)
Try
MsgBox(Dts.Variables("MyVariable").Value.ToString()) ' this gives the error "Object reference not set to an instance of an object"
Catch ex As Exception
MsgBox(ex.Message.ToString())
End Try
End Sub

Looking forward to seeeing a solution for this.

Thanks

What is the data type of MyVariable? You may need to convert it to the Object data type.|||Have you tried changing the Private modifier on your sub to Public?

Also, you have to make sure that your variable is indeed instantiated. What is the type of your variable? If it is a reference type, it has to be somehow somewhere declared as New.|||

It is a string type variable and it can be accessed in Main() method without any problem. I made the event method as public but no luck. Also note that variable has been added to SSIS with scope of the "project". This problem not just for this variable, No variables can be accessed through the event method.

Any suggestions?

Thanks

|||Hmmm...

Dim watcher As New FileSystemWatcher()

Shouldn't it be:

Dim WithEvents watcher as New FileSystemWatcher()|||

Not sure why it does not work, but I have found writing custom tasks is often easier when trying anything other than simple stuff, if only because I can choose my language, and the IDE is much better. Not much use, but perhaps this would be -

File Watcher Task (http://www.sqlis.com/23.aspx)

|||

Hi Jon, Darren

Thanks for reply. I tried with WithEvents but it didn't work again. I have tried FileWatcherTask (sqlis) before but one biggest problem with it is, it stops listening once the first file is detected.

l'll try to make a custom task and see.

Thanks

Accessing variable inside Script Task

Hi,

I have a variable in SSIS that I want to access inside the Script Task. I assigned the variable in the ReadOnlyVariables in the Script Task property. How do I access it?

cherriesh

Try

Dim Avariable As Variables
Dts.VariableDispenser.LockForRead("YourPackageVariable")
Dts.VariableDispenser.GetVariables(Avariable)

see

Monday, February 13, 2012

Accessing Reports through Internet

Hi,
is it possible to put a Report Server on a computer inside a DMZ and the
SQL-Server 2005 in the secure area?
For simplicity we want to use two or three local windows-system accounts to
log in through a web browser to the Report Manager (authentication via IIS
on the computer with the ReportServer). Then we want the reports to use
datasources behind the firewall with stored
credentials. Is this scenario possible? Are there any drawbacks?Did you able to make this architecture work? I am also having the same
situation.
"Ralph Watermann" wrote:
> Hi,
> is it possible to put a Report Server on a computer inside a DMZ and the
> SQL-Server 2005 in the secure area?
> For simplicity we want to use two or three local windows-system accounts to
> log in through a web browser to the Report Manager (authentication via IIS
> on the computer with the ReportServer). Then we want the reports to use
> datasources behind the firewall with stored
> credentials. Is this scenario possible? Are there any drawbacks?
>
>
>|||Hi,
As indicated by MS, this should works. But practical speaking, you'll face
at least 2 no go issues:
1. Your window credential will not be authenticated as the RS server in DMZ,
which means RS server and user are not in same domain and they don't trusted
each other.
2. The RS server can't be setup. RS server in DMZ, and SQL in secure zone
means they're in different domain. They will not trust each other thus not
way you can run the setup.
regards,
Joe
"Nanda Sundaresan" wrote:
> Did you able to make this architecture work? I am also having the same
> situation.
> "Ralph Watermann" wrote:
> > Hi,
> >
> > is it possible to put a Report Server on a computer inside a DMZ and the
> > SQL-Server 2005 in the secure area?
> >
> > For simplicity we want to use two or three local windows-system accounts to
> > log in through a web browser to the Report Manager (authentication via IIS
> > on the computer with the ReportServer). Then we want the reports to use
> > datasources behind the firewall with stored
> > credentials. Is this scenario possible? Are there any drawbacks?
> >
> >
> >
> >
> >