Resetting Varible value in Script task
Hi,I am in process of lodging audit information into audit table after suceessfull run of a dataflow (used Execute sql transformation in PostExecute event). I am using a script task to re-set the variable value to 0 after. But when I try to reset the variable in the Script task, I am getting error. the warning message is,"Error1Non-invocable member 'Microsoft.SqlServer.Dts.Tasks.ScriptTask.ScriptObjectModel.Variables' cannot be used like a method."The code I am using is, using System; using System.Data; using Microsoft.SqlServer.Dts.Runtime; using System.Windows.Forms; namespace ST_8000d03b08654682a0bb7945dcfeeea0.csproj { [System.AddIn. AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")] public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase { #region VSTA generated code enum ScriptResults { Success = Microsoft.SqlServer.Dts.Runtime. DTSExecResult.Success, Failure = Microsoft.SqlServer.Dts.Runtime. DTSExecResult.Failure }; #endregion /* The execution engine calls this method when the task executes. To access the object model, use the Dts property. Connections, variables, events, and logging features are available as members of the Dts property as shown in the following examples. To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value; To post a log entry, call Dts.Log("This is my log text", 999, null); To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true); To use the connections collection use something like the following: ConnectionManager cm = Dts.Connections.Add("OLEDB"); cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;"; Before returning from this method, set the value of Dts.TaskResult to indicate success or failure. To open Help, press F1. */ public void Main() { // TODO: Add your code here Dts.Variables( "User::InsertCount") = 0; Dts.TaskResult = ( int)ScriptResults.Success; } } } Kindly help me to resolve this. I have downloaded the logging example appliation posted by Jamie at http://blogs.conchango.com/jamiethomson/archive/2005/06/11/SSIS_3A00_-Custom-Logging-Using-Event-Handlers.aspx. The script task environemnt and coding is entirely different between the sample application and my etl package. i am using Sql server 2008 on window 2008 server.Best regards,Sengwa
August 18th, 2009 9:55pm

Assure that the variable is set to ReadWrite and use: Dts.Variables( "User::InsertCount").Value = 0;David Dye
Free Windows Admin Tool Kit Click here and download it now
August 18th, 2009 10:00pm

Thanks for your reply Dave. I have done this. I already assigned this variable to ReadandWrite property in the script task and using following code to re-set: Dts.Variables("User::InsertCount").value = 0; when I try to build, I am getting "Error 1 Non-invocable member 'Microsoft.SqlServer.Dts.Tasks.ScriptTask.ScriptObjectModel.Variables' cannot be used like a method" error. Kindly let me know what i am missing in the code. Best regards, Sengwa
August 18th, 2009 10:48pm

Hi, I guess u are using C# to code. you need to use [] instead of (). Dts.Variables["User::InsertCount"].Value = 0Hope this helps !! Please mark the post(s) as Answered / Helpful that helped you - Sudeep
Free Windows Admin Tool Kit Click here and download it now
August 18th, 2009 11:06pm

Thanks Sudeep and Dave. It worked. Thanks a ton for your help. really appreciate this.
August 19th, 2009 5:45pm

Thanks so much Sundeep that did it for me.
Free Windows Admin Tool Kit Click here and download it now
February 14th, 2011 1:32pm

Here is an example (C#) of how to read and write variables in a Script Task: http://microsoft-ssis.blogspot.com/2010/12/how-to-use-variables-in-script-task.html Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com
February 14th, 2011 2:09pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics