Update SSIS Object Variable Used In Foreach Conainer From Script Task?

Jul 30, 2007

Hello,


I have a SSIS package that has a SQL task which gets a result set and stores it in an SSIS object variable. The package then iterates through that result set in a foreach Loop Container. In the loop container I have a script task and a Send Mail Task. The script task sets the contents of the email message (through an SSIS String variable).
In the dataset I have an EmployeeCode column. I need to select a single EmployeeCode and grab all the records associated with that code to create a single EmailMessage for that Employee that includes all their records. I've got that done, however the way I'm implementing it I then have to update the SSIS Object variable that holds the result set to remove those records I've already processed. Doing this causes an error at the next ForEach loop iteration stating it can't find a source.


Result Set from SQL Query (16 columns, 674 rows, 145 distinct Employeecodes)
Employee Code EmailAddress Other columns
1 email1 set1
1 email1 set2
2 email2 set3
2 emial2 set4
2 email2 set5
etc etc etc


The first iteration should be sent to email1 where the body includes set1 and set2, the second iteration sends to email2 where the body includes set3, set4, and set5 and so forth.


The SSIS ForEachLoop Container is looping through the entire Result Set and passing into the .NET Script task the EmployeeCode (readonly) and the entire Result Set (readwrite) and setting the value of EmailMessage. So I create the value of EmailMessage based on the EmployeeCode and then use the value of Email1 and EmailMessage in the SendMail Task. I was trying to delete the rows I processed so I don€™t process them the next time the ForEachLoop Executes (otherwise I'll get duplicate emails).


Or if there's a different way to do this, I'm open to that as well.


See below for the code I'm using (colEmployeeCode is a ReadOnlyVariable and rsRecipients and EmailMessage are ReadWriteVariables in the Script Task).


Public Sub Main()
Dim Header As String
Dim Body As String
Dim Footer As String
Header = "blah"

Footer = "blah"

Try
Dim olead As New Data.OleDb.OleDbDataAdapter
Dim dt As New Data.DataTable
olead.Fill(dt, Dts.Variables("rsRecipients").Value)

For Each row As Data.DataRow In dt.Rows
If UCase(Trim(row("EmployeeCode").ToString())) = UCase(Trim(Dts.Variables("colEmployeeCode").Value.ToString())) Then
Body = Body + "Label: " + Trim(row("colum").ToString()) + System.Environment.NewLine
row.Delete()
End If
Next
Dts.Variables("rsRecipients").Value = dt
Dts.Variables("EmailMessage").Value = Header + Body + Footer
Dts.TaskResult = Dts.Results.Success
Catch ex As Exception
Dts.TaskResult = Dts.Results.Failure
End Try
End Sub


Thank you very much,

Aaron

View 3 Replies


ADVERTISEMENT

OK So How Do You Start An SSIS Package With A ForEach And A WMI File Watch Task?

Mar 21, 2007

Can't an SSIS package run "in the background", so to speak, without having either the cmd.exe or dtexecui windows open while executing? I'd obviously rather not have to have a window open when the thing is running right?

View 2 Replies View Related

Extracting Contents Of Object Variable In Script Task

Feb 23, 2007

Hey Guys,

Im pretty new to Scripting in SSIS, but i have worked a fair bit out already, although i am stuck with the following problem.. If anyone can help out that would be great!!

Ok, i have a package that loops through records in a table, and extracts the detailed lines in a For Each loop. and stores them in a variable called DetailRecordSet with an data type of object.

I have a built a script task so that i can send out an email confirmation for each order, and i want to list the details in a HTML Table in the body of the message ( I have read that the standard send mail task wont support this, but found an example of using .NET code to generate the email message which will support it) .


What i want to know is how do i reference the columns in the Object variable so i can extract each line and add it into my string that i am creating with HTML codes.. I



e:( str = "<TABLE> <TR>" + Cstr(Variable for 1st column in recordset) + " </TR>"

if any can help my, that would be most appriciated.. Ive tried all different things that ive found on the net, but nothing is working.

Thanks in Advance

Scotty

View 3 Replies View Related

SSIS Script Task Alters Package Variable, But Variable Does Not Change.

Oct 25, 2006

I'm working on an SSIS package that uses a vb.net script to grab some XML from a webservice (I'd explain why I'm not using a web service task here, but I'd just get angry), and I wish to then assign the XML string to a package variable which then gets sent along to a DataFlow Task that contains an XML Source that points at said variable. when I copy the XML string into the variable value in the script, if do a quickwatch on the variable (as in Dts.Variable("MyXML").value) it looks as though the new value has been copied to the variable, but when I step out of that task and look at the package explorer the variable is its original value.

I think the problem is that the dataflow XML source has a lock on the variable and so the script task isn't affecting it. Does anyone have any experience with this kind of problem, or know a workaround?

View 1 Replies View Related

Passing A SSIS Global Variable To A Declared Variable In A Query In SQL Task

Mar 6, 2008

I have a SQL Task that updates running totals on a record inserted using a Data Flow Task. The package runs without error, but the actual row does not calculate the running totals. I suspect that the inserted record is not committed until the package completes and the SQL Task is seeing the previous record as the current. Here is the code in the SQL Task:

DECLARE @DV INT;
SET @DV = (SELECT MAX(DateValue) FROM tblTG);
DECLARE @PV INT;
SET @PV = @DV - 1;

I've not been successful in passing a SSIS global variable to a declared parameter, but is it possible to do this:

DECLARE @DV INT;
SET @DV = ?;
DECLARE @PV INT;
SET @PV = @DV - 1;


I have almost 50 references to these parameters in the query so a substitution would be helpful.

Dan

View 4 Replies View Related

Integration Services :: Joining Object Variable Values In Script Task

Jul 23, 2015

I have a object variable named "UserList" which gets populated through execute sql task - stored procedure.I wish to concatenate all the values in "UserList" using ssis script task - in lang vb.Output should be like (User1,User2,User3,....)

View 8 Replies View Related

Passing Object Variable As Input Parameter To An Execute SQL Task Query

Mar 29, 2007

I've encountered a new problem with an SSIS Pkg where I have a seq. of Execute SQL tasks. My question are:

1) In the First Execute SQL Task, I want to store a single row result of @@identity type into a User Variable User::LoadID of What type. ( I tried using DBNull Type or Object type which works, not with any other type, it but I can't proceed to step 2 )



2) Now I want to use this User::LoadID as input parameter of What type for the next task (I tried using Numeric, Long, DB_Numeric, Decimal, Double none of there work).



Please give me solutions for the above two..



View 6 Replies View Related

Integration Services :: How To Access Object Type Variable In Execute Task

Nov 18, 2015

In my ssis 2012 package, I have a 'object' type variable with some table like records. I want to do some SQL operations like insert/update on the records in another table based on this 'Object' type variable records. Basically I want to use a MERGE statement with another physical table with the records in the 'Object' type variable.how to map/use the Object type variable in Execute sql task.I am not good in script task. How to utilize this Object variable in a Execute sql task?  

View 9 Replies View Related

Send Mail Task Problem Using A Combination Of ForEach Loop, Recordset Destination, Execute SQL Task And Script Task

Jun 21, 2007

OK. I give up and need help. Hopefully it's something minor ...



I have a dataflow which returns email addresses to a recordset.

I pass this recordset into a ForEachLoop configuring the enumerator as (Foreach ADO Enumerator). I also map the email address as a variable with index 0.



I then have a Execute SQL task which receives this email address as a varchar variable (parameter 0) which I then use in my SQL command to limit the rows returned. I have commented out the where clause and returned all rows regardless of email address to try to troubleshoot this problem. In either event, I then use a resultset to store the query result of type object and result name 0.



I then pass this resultset into a script variable to start parsing the sql rows returned as type object. ( I assume this is the correct way to do this from other prior posts ...).



The script appears to throw an exception at the following line. I assume it's because I'm either not passing in the values properly or the query doesn't return anything. However, I am certain the query works as it executes just fine at the command prompt.



Try

ds = CType(Dts.Variables("VP_EMAIL_RESULTS_RS").Value, DataSet)



My intent is to email the query results to each email address with the following type of data by passing the parsed data from the script to a send mail task. Email works fine and sends out messages but the content is empty. I pass the parsed data as string values to the messagesource and define the messagesourcetype as a variable in the mail task.



part number leadtime

x 5

y 9

....



Does anyone have any idea what I might be doing wrong?

thanks

John

View 5 Replies View Related

Integration Services :: Using Object Variable In SSIS?

Aug 17, 2015

I have one scenario. I am calling all columns result set to an variable and inside for each loop container using script task to get message about how many columns are coming in the loop.

At last using send mail task to send automated mails to group of people,but issue it is taking only person's mail id and coming out of loop.

how to call object type variable ?

View 4 Replies View Related

SSIS Package Foreach Loop Container - For Each File Enumerator - Ger Enumerator Configuration From Variable

Apr 21, 2008



Hello

I am trying to use Foreach loop container - Foreach File Enumerator

Is there easy way to retrieve enumerator configuration folder from variable - so I can easily move package from server to server?

I would like to have name of the folder we getting files from retrieved from variable by using this control

Thank you in advance
Armine Bell

View 3 Replies View Related

SSIS Transfer Database Object Task

Sep 13, 2007

Hi everyone
Can any one help me I am using Tranfer databse object task when I am trying to run it its throwing exception can not send null value in login name????

View 7 Replies View Related

SSIS Transfer Object Task Error - Selecting Tables To Copy

May 4, 2007

I'm using a Business Intelligence project to copy stored procedures and tables from one database to another across servers. I'm having trouble copying tables or stored procedures using the Management.SMO.Transfer class.



I tried copying stored procedure with the property transfer.CopyAllStoredProcedures = true. This didn't work. As a workaround, I used the StringCollection property and executed every string as sql.



Now I'm having trouble copying tables. I don't want to copy all the tables in the database. How do I go about selecting what tables to copy. I tried using ObjectList property and provided the names of the tables in an ArrayList. I get the error

"Transfer cannot process System.String. You need to pass an instance class object."



How can I pass an "instance class object" for something that's in the database? The ScriptTransfer method fails so I can't even see the script that is being generated. There is virtually no documentation for this class.



Any help will be appreciated.



Transfer transfer = new Transfer();

transfer.Database = sourceDB;

transfer.DestinationDatabase = DestinationDatabase;

transfer.DestinationServer = DestinationServer;

transfer.DropDestinationObjectsFirst = false;

transfer.CopyData = true;

transfer.CopySchema = true;

transfer.CopyAllObjects = false;

transfer.CopyAllTables = false;

transfer.CopyAllStoredProcedures = false;

transfer.Options.WithDependencies = false;

GetTablesToBeCopied();

transfer.ObjectList = tablesList;



transfer.Options.FileName = "C:\TransferScriptTables.sql";



StringCollection coll = transfer.ScriptTransfer();

View 3 Replies View Related

Using Variable In Execute SQL Task In SSIS

Mar 12, 2008



Hi

I need to use a variable as column in SQL statement in Execute SQL task of integration services. I am setting Parameter Setting to map variable use it in the query like; select ? , col1name from tablename. But its not working.
Anybody having any idea; would be of great help.

Thanks,
Salman Shehbaz.

View 3 Replies View Related

Integration Services :: Execute Task Does Not Update From Date Variable Reliably

Oct 23, 2014

I'm using a DateTime variable in SSIS 2008 that is used to set the SQLStatement property of an Execute SQL Task.

"DELETE FROM Labor WHERE Week = '" + (DT_WSTR, 100) @[User::Week] + "'"

Week is the next Sunday:
DATEADD( "day", @[User::DaysTillSunday] , @[User::TheDayThatIsTwentyMinutesPrior] )
DaysTillSunday:
DATEPART( "dw", @[User::TheDayThatIsTwentyMinutesPrior] ) == 1 ? 0 : 8 - DATEPART( "dw", @[User::TheDayThatIsTwentyMinutesPrior] )

TheDayThatIsTwentyMinutesPrior:
(DT_DATE)(DT_DBDATE)DATEADD("minute",-20,GETDATE())

The SSIS Package deletes the current week's data, reloads it with fresh data, then calculates the difference between the current week and last week.

The problem is that randomly, instead of deleting the current week, it will delete the previous week.  This happens maybe 5-10% of the time.  At least it does until I rebuild the package and import it into SQL Server again.

I'm guessing that the Execute SQL Task is not updating the value of the Week variable before it executes.  I started with the source type being a variable.  Then I decided to try Direct input and pass in the Week as a parameter (OLE DB Connection Type).  That didn't work either.

Most recently I tried writing the Week variable to a table first, then having a sequence container with all the tasks second.  Slightly better but I still saw the date was wrong 2 times in about 90 executions.  I was hoping that writing the Week variable out to the database would force an update of any associated connections to it, but that didn't seem to work.

View 18 Replies View Related

Not Executing SSIS SQL Task By Passing Variable

Jun 11, 2008

Hi,

I am creating SSIS package which using Execute SQL Task to which I am supplying one .sql file code is

delete from Test where ID = @ID

I defined @ID variable to SSIS and also path where .sql file placed but i am not able to execute this package i am getting error like can not find C:@Path file......

As i got information that passing such variable to .sql you need ADO.net connection so I changed SQLSERVER Database connection string to ADO.net .... after that when i set hard core value for these variable i.e for @ID and @Path then it runs sccessfully but by setting parameter i am getting above error


Any suggestion that will be gr8 help for me

T.I.A

View 2 Replies View Related

SSIS Task Script Dts.Variable Error

Feb 12, 2008

Hello everyone,

This is my first post. :-)

I've been having an error with Script Tasks in SSIS, where the error is every time I use a For Each In Dts.Variables, it always seems to crash. I'm trying to log the variables before I proceed in any other tasks. I'm passing in one value as a ReadOnlyVariables.

Here is the snippet of code:

Dts.Log(String.Format("{0} variables:", Dts.Variables.Count), 0, Nothing)
For Each v As Variable In Dts.Variables
Dts.Log(String.Format("{0} = {1}", v.Name, v.Value), 0, Nothing)
Next

It's very strange because the Dts.Variables.Count gives me the correct number of items that I have passed in, but after I step into the For Each, I get this for Dts.Variables.Item:

In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user. Microsoft.SqlServer.Dts.Runtime.Variable

And as soon as I step into the next line, it crashes with this error:

Value does not fall within the expected range.
at Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSVariables90.GetEnumerator()
at Microsoft.SqlServer.Dts.Runtime.Variables.GetEnumerator()
at ScriptTask_932938a13af547149ade0331cf39ecfe.ScriptMain.Main()


My colleagues have tried this snippet of code and it worked fine on their machine, only mine has this error :-(

I tried to do several searches online and they recommended me to:
Get the latest SP (I have all the updates now for .net and SQL)
Re-register some .dll's such as dts.dll/pipeline/etc
Change/toggle the PreCompileBinary
Alter the script a little and rebuild.

None of these suggestions have had any success on this error that I'm having. I was wondering if anyone had any insight or had any similar problems as me. Any help would be much appreciated!

Thanks,
-Simon
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

View 8 Replies View Related

Integration Services :: SSIS Connection Object Update Failing

Jun 29, 2015

I built a small package two years ago that uses Flat File Sources to copy in small text data files.  Each source connection object has a UNC path to flat text files on another server.  The source system changed, so I opened the package and updated the UNC path in one Connection Manager object, and clicked OK. The Flat File Source Editor that uses this source seemed to be able to see the new location when I clicked "Preview".  Then I went back to the file source, and the connection had reverted back to the original one.  it would not save the new UNC path.  

I am using SQL Server 2012 SP2 with SSDT (run as admin).  I closed the package in SSDT, edited the connection strings using XMLnotepad, and was then able to open, test, build and deploy the package.

It seems that the Source object will not let itself be changed.  The other option is to delete it and recreate it, but I didn't want to remap the fields.

Why updating a connection object is not working?

View 5 Replies View Related

Xml Result Set To A Variable In Ssis And To Access It In Script Task

Apr 28, 2007

Hi!

I have an sproc that gives an xml result set. I want to save this to a file but by using ssis and script task. Now, I do exec usp_myProc in execute sql task and get the result as xml. (I can get it as result set too but niether has worked). Now I pass this variable to my script task User::XRset.

In the script task I create a file and then I want to write xml result of User::XRset to my file. I am at loss.

View 4 Replies View Related

SSIS FTP Task Variable Remote Path Invalid

Jun 17, 2006

I am working on the SSIS FTP Task that transfer file from one FTP server to local location, rename the file name, and finally transfer the renamed file to another FTP server. So I defined 2 FTP tasks.

For the FTP file receive operation, I need the remote path to be updated by a script and pass to the user define variable. So I set TRUE to IsRemotePathVariable. In the RemoteVariable, I set User::FTPSourcePath where the variable is set in the script with "/DMFTP/filename1.jpg"

For the FTP file send operation, I set TRUE to IsRemotePathVariable. In the RemoteVariable, I set User::FTPDestPath where the variable is set in the script with "/DestFTP/"

After all the setting, the FTP Task box show me the error as "Variable "FTPSourcePath" doesn't start with "/". Another FTP box show me "Variable "FTPDestPath" doesn't start with "/"

Can anyone help me on this problem?? Thanks.

View 30 Replies View Related

Integration Services :: Send Email Task With Variable In SSIS

Oct 5, 2015

I would like to send an email in a SSIS Package.

I have an Execute SQL Task that saves the results in a variable such as, RecCounts.

I have a Send Mail Task with a message source of: [User::RecCounts]

However, when I run the package I get this error.

Error: Failed to lock variable "[User::RecCounts]" for read access with error 0xC0010001 "The variable cannot be found.

This occurs when an attempt is made to retrieve a variable from the Variables collection on a container during execution of the package, and the variable is not there. The variable name may have changed or the variable is not being created.".

View 4 Replies View Related

Store Varbinary Data Result Into SSIS Variable Through Execute SQL Task

Feb 13, 2008

I cannot find the data type for parameter mapping from Execute SQL Task Editor to make this works.

1. Execute SQL Task 1 - select max(columnA) from tableA. ColumnA is varbinary(8); set result to variable which data type is Object.

2. Execute SQL Task 2 - update tableB set columnB = ?
What data type should I use to map the parameter? I tried different data types, none working except GUI but it returned wrong result.

Does SSIS variable support varbinary data type? I know there's a bug issue with bigint data type and there's a work-around. Is it same situation with varbinary?

Thanks,

-Ash

View 8 Replies View Related

Foreach From Variable Using 2 Dim Array Variable

May 15, 2007



Is there any way to use a 2 dimensional array of strings as the Variable Enumerator for the "Foreach From Variable Enumerator". I am trying to copy a collection of files from folder A to folder B. In a script, I would populate, let us say, an array of (2,10), for 10 files, with one column representing the source file and other column representing the target column task. Then I would like to set this string array variable as the "Variable Enumerator" for the "Foreach From Variable Enumerator" and use file system tasks in the foreach loop to perform the tasks. The problem is that the "Foreach From Variable Enumerator" does not let me choose an index, but passes only one index 0, so, I will only be able to pass just one column. How do I let the foreach enumerator let me choose an index. The other foreach enumerators, foreach item and ADO give me the option to select index. I would like the same functionality in the foreach variable.

Note: I cannot use the "For Each File" enumerator, since the files are to be selected by a script only.
Thanks for the help.

View 3 Replies View Related

Integration Services :: Assign Value Of Aggregate Transform To A Variable Without Using Script Task In SSIS

Jun 2, 2011

In my current project i have a requirement to assign value of an aggregate transform to a variable. But i need to accomplish it without using a script task.

View 3 Replies View Related

Using A Variable In An Expression To Populate The Executable Property Of An Execute Process Task In SSIS

Jan 22, 2008

Hello,

I am having a hard time setting the executable path for an Execute Process Task in SSIS. I have a variable that is initialized at package statup which holds the path to an executable in Windows. When I set the property "Executable" Path in an expression, I get a warning that the path for the executable is not set. One workaround was to try and initialize the variable with a bogus path with the hopes that the "correct" value will be written on run-time. NO LUCK. I still get the error and I cannot run the package until I put a static path.

Does anyone have a clue as to what is going on??

Mike

View 1 Replies View Related

In SSIS Execute SQL Task, Single-row Result From Querying Mysql Binding With A Variable

Jul 20, 2007

I set up a connection to mysql using ADO.NET's ODBC Data Provider. And I'm running a simple query to return one table's maximum ID(int32 unsigned). There is no problem to achieve that.



But when I bind the result to a variable and excute task. It gives out error message: "An error occurred while assigning a value to variable "MaxAuditLogID": "Result binding by name "MaxID" is not supported for this connection type. "



I tried to change the type of variable around but with no luck.



Could anyone help with this issue? Thanks!

View 6 Replies View Related

Shredding Recordset Object Var In ForEach Loop (problem)

Feb 14, 2006

I have a package that starts by loading a recordset into an object variable. The recordset is then enumerated with a ForEach loop. The loop sets some string variables. Within the loop container I have a Script task that uses a MsgBox to show the results for testing purposes. The package uses checkpoint restart (if that matters?).

The first time I run the package the 1st record is displayed in the MsgBox, then the 2nd, but then the loop is stuck on the 2nd record forever. I break the run, and when I rerun it the 1st record is displayed followed by each subsequent record correctly and the package completes successfully. Now, if I were to run again the same problem would occur on rec 2 and I would have to break the run, and then the next run everything would work fine.

Why does the script get caught in an infinite loop the first time it's run, but works fine when restarting from the checkpoint?

Here's my relevant code:





ForEach: Enumerator=ADO Enumerator, Enumeration Mode=Rows in first table




Public Sub Main()
Dts.Variables("User::SQL1").Value = "SELECT src.* FROM " & Trim(Dts.Variables("User::Src1Tbl").Value.ToString)
MsgBox("sql=" & Dts.Variables("User::SQL1").Value.ToString)
Dts.TaskResult = Dts.Results.Success
End Sub

View 8 Replies View Related

Using A Variable In SSIS - Error - Command Text Was Not Set For The Command Object..

Nov 4, 2006

Hi All,

i am using a OLE DB Source in my dataflow component and want to select rows from the source based on the Name I enter during execution time. I have created two variables,

enterName - String packageLevel (will store the name I enter)

myVar - String packageLevel. (to store the query)

I am assigning this query to the myVar variable, "Select * from db.Users where (UsrName = " + @[User::enterName] + " )"

Now in the OLE Db source, I have selected as Sql Command from Variable, and I am getting the variable, enterName,. I select that and when I click on OK am getting this error.

Error at Data Flow Task [OLE DB Source [1]]: An OLE DB error has occurred. Error code: 0x80040E0C.
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E0C Description: "Command text was not set for the command object.".

Can Someone guide me whr am going wrong?

myVar variable, i have set the ExecuteAsExpression Property to true too.

Please let me know where am going wrong?

Thanks in advance.








View 12 Replies View Related

Script Task Error --Object Reference Not Set To An Instance Of An Object

Sep 13, 2006

I am trying to execute this code feom Script task while excuting its giving me error that "Object reference not set to an instance of an object." The assemblies Iam referening in this code are there in GAC. Any idea abt this.



Thanks,

Public Sub Main()

Dim remoteUri As String

Dim fireAgain As Boolean

Dim uriVarName As String

Dim fileVarName As String

Dim httpConnection As Microsoft.SqlServer.Dts.Runtime.HttpClientConnection

Dim emptyBytes(0) As Byte

Dim SessionID As String

Dim CusAuth As CustomAuth

Try

' Determine the correct variables to read for URI and filename

uriVarName = "vsReportUri"

fileVarName = "vsReportDownloadFilename"

' create SessionID for use with HD Custom authentication

CusAuth = New CustomAuth(ASCIIEncoding.ASCII.GetBytes(Dts.Variables("in_vsBatchKey").Value.ToString()))



Dts.Variables(uriVarName).Value = Dts.Variables(uriVarName).Value.ToString() + "&" + _

"BeginDate=" + Dts.Variables("in_vsBeginDate").Value.ToString() + "&" + _

"EndDate=" + Dts.Variables("in_vsEndDate").Value.ToString()

Dim request As HttpWebRequest = CType(WebRequest.Create(Dts.Variables(uriVarName).Value.ToString()), HttpWebRequest)

'Set credentials based on the credentials found in the variables

request.Credentials = New NetworkCredential(Dts.Variables("in_vsReportUsername").Value.ToString(), _

Dts.Variables("in_vsReportPassword").Value.ToString(), _

Dts.Variables("in_vsReportDomain").Value.ToString())

'Place the custom authentication session ID in a cookie called BatchSession

request.CookieContainer.Add(New Cookie("BatchSession", CusAuth.GenerateSession("EmailAlertingSSIS"), "/", Dts.Variables("in_vsReportDomain").Value.ToString()))

' Set some reasonable limits on resources used by this request

request.MaximumAutomaticRedirections = 4

request.MaximumResponseHeadersLength = 4

' Prepare to download, write messages indicating download start

Dts.Events.FireInformation(0, String.Empty, String.Format("Downloading '{0}' from '{1}'", _

Dts.Variables(fileVarName).Value.ToString(), Dts.Variables(uriVarName).Value.ToString()), String.Empty, 0, fireAgain)

Dts.Log(String.Format("Downloading '{0}' from '{1}'", Dts.Variables(fileVarName).Value.ToString(), Dts.Variables(uriVarName).Value.ToString()), 0, emptyBytes)

' Download data

Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)

' Get the stream associated with the response.

Dim receiveStream As Stream = response.GetResponseStream()

' Pipes the stream to a higher level stream reader with the required encoding format.

Dim readStream As New StreamReader(receiveStream, Encoding.UTF8)

Dim fileStream As New StreamWriter(Dts.Variables(fileVarName).Value.ToString())

fileStream.Write(readStream.ReadToEnd())

fileStream.Flush()

fileStream.Close()

readStream.Close()

fileStream.Dispose()

readStream.Dispose()



'Download the file and report success

Dts.TaskResult = Dts.Results.Success

Catch ex As Exception

' post the error message we got back.

Dts.Events.FireError(0, String.Empty, ex.Message, String.Empty, 0)

Dts.TaskResult = Dts.Results.Failure

End Try

End Sub

View 1 Replies View Related

Update SSIS Variables Inside DTS Task ?

Mar 12, 2008

Hi all,

I use a "Exec DTS 2000" task.

I have a variable user::MYVAR in my SSIS package, wich value is "PARENT".

I pass this variable as an outer variable to my dts 2000 package, wich receive it correctly, and then update it to "UPDATED".

After this task finishes, when I come back to SSIS, MYVAR is still at "PARENT".


Is it possible to see the update from the parent package ?


Thanks

View 6 Replies View Related

Getting Object Reference Not Set To An Instance Of An Object In Execute SQL Task

Jun 6, 2007



When I try and parse a simple execute of a stored procedure in the Execute SQL Task Editor, I get the error:



"Object reference not set to an instance of an object"



Now, I ONLY get this error on my laptop, so I'm assuming it might be an installation error. I've tried to do the exact same thing in other environments, and received no error. Here's what I'm doing:



1. I create a simple stored procedure on a SQL 2005 database. Here's what it does:



create proc usp_testsp

as

begin

select 'whatever' ;

end



2. I create a new SSIS package in BIS.

3. I create an ADO.NET connection to the above SQL 2005 database

4. I pull over an Execute SQL Task item from the toolbox to the Control Flow tab.

5. I choose the ADO.NET connectiontype, the connection I created in #2, SQLSourceType of Direct input, SQLStatement is: exec usp_testsp, IsQueryStoredProcedure set to True. And I try ResultSet as both Single row and None



When I try to Parse the Query, I get the above error. If I still try to run the task in the debugger, here's what I get with the ResultSet set to None:



Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "exec usp_testsp" failed with the following error: "Could not find stored procedure 'exec usp_testsp'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.



And just so you know, I can execute the sp with no problems. And just to check, I granted execute to public on the sp.



And here's what I get with ResultSet set to Single row:



Error: 0xC00291E2 at Execute SQL Task, Execute SQL Task: There is an invalid number of result bindings returned for the ResultSetType: "ResultSetType_SingleRow".



I only get this on my laptop. I have SQL Server 2005 SP2 Developer Edition on Windows XP Professional, SP2.



Thanks,

Michael





View 3 Replies View Related

Script Task Component: Object Not Set To Instance Of Object

May 19, 2008

i have some code in a script task component which is meant to find a cell in an excel sheet and assign a variable to its value in the script component. I receive an error that the object is not set in instance of object. below is the code which i tried to simplify to find the error, but it is still occurring. any help would be appreciated. thank you



Dim vars As IDTSVariables90

vars.Unlock()

Me.VariableDispenser.LockForWrite(Variables.freq)

Variables.freq = "1"

View 1 Replies View Related

EXECUTE SQL TASK --&&> Object Reference Not Set To An Instance Of An Object

Jun 27, 2007






Hi all,

Does anyone see the error below before?
I am using SSIS Execute SQL Task (ADO.NET) to update a table using a stored procedure.
It works like this many times for me and all of a sudden, not sure what is changing in the environment, I kept getting this WARNING when I click on PARSE QUERY
€œObject Reference Not Set to An Instance of an Object€? when I click on PARSE QUERY.

This is going against SQL SERVER 2005 SP2 x64 Enterprise.

Note that this task executes fine and the stored procedure updates data.

The stored procedure does the following.
There are other stored procedures of different kinds and they all worked.
But all of them give this error when I click on PARSE QUERY.




Code Snippet
DECLARE @TodayDate datetime
SET @TodayDate = GETDATE()

Exec dbo.updDimBatch
@BatchKey = @BatchKey,
@ParentBatchKey = @ParentBatchKey,
@BatchName = 'Load Customer Increment',
@BatchStartDate = NULL,
@BatchEndDate = @TodayDate,
@StatusKey = NULL,
@RowsInserted = @Count_Insert,
@RowsUpdated = @Count_Update,
@RowsException = NULL,
@RowsError = NULL,
@UpdatedDate = @TodayDate,
@BatchDescription = NULL

OLEDB Sample also give me syntax error

exec dbo.updDimBatch ?,?,'Load Activity Increment','6/27/2007','6/27/2007',1,?,?,0,0,'6/27/2007',''






I tried to change to OLEDB and call the stored procedure like this but got syntax error?

Not sure what is the error here.









View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved