need help with script task codes
Hi everyone,i have this error when running my ssis. it gave me an error at the script task. Information: 0x40016038 at Cntr_Aging_Data_Dump: The package is attempting to configure from the environment variable "DBServerName". SSIS package "Cntr_Aging_Data_Dump.dtsx" starting. Information: 0x4004300A at Data Dump, DTS.Pipeline: Validation phase is beginning. Error: 0x4 at Init Variables: The Script returned a failure result. Task failed: Init Variables Warning: 0x80019002 at Cntr_Aging_Data_Dump: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors. SSIS package "Cntr_Aging_Data_Dump.dtsx" finished: Failure. my code is this. Imports System Imports System.Data Imports System.Math Imports Microsoft.SqlServer.Dts.Runtime Public Class ScriptMain Public Sub Main() Dim sqlConnStr As String = "Data Source=" & RdVarStr("DB_Server_Name") & ";Initial Catalog=" & RdVarStr("DB_Init_Cat") & ";Integrated Security=True;" Dim varName As String Dim varValue As Object Dim sql As String SetReportName() Try ' 1. Initial variables using all configured value for SSIS in database Using sqlConn As New Data.SqlClient.SqlConnection(sqlConnStr) sqlConn.Open() Using sqlCmd As New Data.SqlClient.SqlCommand(sql, sqlConn) Dim sqlDtReader As Data.SqlClient.SqlDataReader sqlDtReader = sqlCmd.ExecuteReader() While (sqlDtReader.Read) varName = CStr(sqlDtReader.GetValue(0)) varValue = sqlDtReader.GetValue(1) If (WriteVariable(varName, varValue)) Then Dts.Log("Value of " & varName & " is " & RdVarStr(varName), 0, Nothing) Else Dts.Log("Variable " & varName & " does not exist in the variable list!", 0, Nothing) End If End While sqlDtReader.Close() End Using End Using SetDates() Dts.TaskResult = Dts.Results.Success Catch ex As Exception Dts.Log(ex.ToString, 0, Nothing) WriteVariable("Error_Message", "TaskName:" & RdVarStr("TaskName") & vbCrLf & "ExceptionMessage:" & ex.ToString & vbCrLf) Dts.TaskResult = Dts.Results.Failure End Try End Sub Private Sub SetDates() Dim Dt As DateTime Dim DtStStr As String Dim DtEdStr As String Dim DtYear As Integer Dim formatStr As String = "yyyyMMdd" Dim DateStr As String = Trim(RdVarStr("Exec_Dt")) If (DateStr = "Default") Then Dt = DateTime.Now DateStr = Format(Dt, formatStr) WriteVariable("Flag_Rerun", "0") ElseIf Format(DateTime.Now, formatStr) = DateStr Then Dt = DateTime.Now WriteVariable("Flag_Rerun", "0") Else Dt = DateTime.ParseExact(DateStr, formatStr, Nothing) WriteVariable("Flag_Rerun", "1") End If Dts.Log("Execution date: " & DateStr, 0, Nothing) WriteVariable("Exec_Dt", DateStr) End Sub Private Function RdVarStr(ByVal varName As String) As String Return CType(ReadVariable(varName), String) End Function Private Function ReadVariable(ByVal varName As String) As Object Dim result As Object Try Dim vars As Variables Dts.VariableDispenser.LockForRead(varName) Dts.VariableDispenser.GetVariables(vars) Try result = vars(varName).Value Catch ex As Exception Throw ex Finally vars.Unlock() End Try Catch ex As Exception Throw ex End Try Return result End Function Private Function WriteVariable(ByVal varName As String, ByVal varValue As Object) As Boolean Dim vars As Variables Try If (Dts.VariableDispenser.Contains(varName)) Then Dts.VariableDispenser.LockForWrite(varName) Dts.VariableDispenser.GetVariables(vars) vars(varName).Value = varValue Return True Else Return False End If Catch ex As Exception Throw ex Finally If Not (vars Is Nothing) Then vars.Unlock() End If End Try End Function Private Sub SetReportName() Dim ReportId As String = Trim(RdVarStr("Report_Id")) Dim ReportFreq As String = Trim(RdVarStr("Report_Freq")) Dim Report_Name As String = ReportId & "_" & ReportFreq Dts.Log("Report_Name: " & Report_Name, 0, Nothing) WriteVariable("Report_Name", Report_Name) End Sub End Class please help me.Thanks
November 4th, 2011 3:29am

can anyone help? please thanks
Free Windows Admin Tool Kit Click here and download it now
November 4th, 2011 4:03am

Are you using dtsConfig?Randy Aldrich Paulo MCTS(BizTalk 2010/2006,WCF NET4.0), MCPD | My Blog
November 4th, 2011 4:33am

what is dtsconfig?
Free Windows Admin Tool Kit Click here and download it now
November 4th, 2011 4:34am

in your script task code the 1st line has variable name as "DB_Server_name" Dim sqlConnStr As String = "Data Source=" & RdVarStr("DB_Server_Name") & ";Initial Catalog=" & RdVarStr("DB_Init_Cat") & ";Integrated Security=True;" But in your message the 1st line says Information: 0x40016038 at Cntr_Aging_Data_Dump: The package is attempting to configure from the environment variable "DBServerName". I think the 2 names are not matching
November 4th, 2011 4:43am

where can i find this DBServerName? Information: 0x40016038 at Cntr_Aging_Data_Dump: The package is attempting to configure from the environment variable "DBServerName".
Free Windows Admin Tool Kit Click here and download it now
November 4th, 2011 4:49am

It depends on the location of variable in the package. Just check the SSIS- > Variables.Randy Aldrich Paulo MCTS(BizTalk 2010/2006,WCF NET4.0), MCPD | My Blog
November 4th, 2011 4:53am

i checked my variable, it is DB_Server_Name.. even if i change all the DB_Server_name to DBServerName, the same error occurs..please help
Free Windows Admin Tool Kit Click here and download it now
November 4th, 2011 4:56am

i used the ctrl+F to find the DBServerName. i found one at the dtsConfiguration at the code of my dtsx. i edited the line < DTS:Configuration><DTS:Property DTS:Name="ConfigurationType">2</DTS:Property><DTS:Property DTS:Name="ConfigurationString">DB_Server_Name</DTS:Property><DTS:Property DTS:Name="ConfigurationVariable">\Package.Variables[User::DB_Server_Name].Properties[Value]</DTS:Property><DTS:Property DTS:Name="ObjectName">Configuration 1</DTS:Property><DTS:Property DTS:Name="DTSID">{C5E0441B-9EE4-4E05-B427-971A248B4C62}</DTS:Property><DTS:Property DTS:Name="Description"></DTS:Property><DTS:Property DTS:Name="CreationName"></DTS:Property></DTS:Configuration> now when i run the ssis. this error occurs. Information: 0x40016038 at Cntr_Aging_Data_Dump: The package is attempting to configure from the environment variable "DB_Server_Name". Warning: 0x80019003 at Cntr_Aging_Data_Dump: The configuration environment variable was not found. The environment variable was: "DB_Server_Name". This occurs when a package specifies an environment variable for a configuration setting but it cannot be found. Check the configurations collection in the package and verify that the specified environment variable is available and valid. Warning: 0x80012059 at Cntr_Aging_Data_Dump: Failed to load at least one of the configuration entries for the package. Check configurations entries and previous warnings to see descriptions of which configuration failed. SSIS package "Cntr_Aging_Data_Dump.dtsx" starting. Information: 0x4004300A at Data Dump, DTS.Pipeline: Validation phase is beginning. Error: 0x4 at Init Variables: The Script returned a failure result. Task failed: Init Variables Warning: 0x80019002 at Cntr_Aging_Data_Dump: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors. SSIS package "Cntr_Aging_Data_Dump.dtsx" finished: Failure.
November 4th, 2011 5:27am

Aren't there any other error messages? (except Error: 0x4 at Init Variables: The Script returned a failure result.)
Free Windows Admin Tool Kit Click here and download it now
November 4th, 2011 5:28am

Your error message is in 4th line of the message "Warning: 0x80019003 at Cntr_Aging_Data_Dump: The configuration environment variable was not found. The environment variable was: "DB_Server_Name". This occurs when a package specifies an environment variable for a configuration setting but it cannot be found. Check the configurations collection in the package and verify that the specified environment variable is available and valid." It says "environment variable was not found" GO To Start -> MyComputer -> Right Click Properties -> Advanced -> Environment Variables There you check for the variable "DB_Server_Name" If not present add the same with the required value
November 4th, 2011 6:40am

Did you set the DB_Server_Name variable as the SQL_Environment? And in the WriteVariable method, you will rewrite the value of this variable, so it will encounter the error when you attempt to set new value to this variable. You can try to set another different variable to store DB_Server_Name. Hope it can help.Best regards Patrick Zeng
Free Windows Admin Tool Kit Click here and download it now
November 4th, 2011 6:42am

Did you set the DB_Server_Name variable as the SQL_Environment? And in the WriteVariable method, you will rewrite the value of this variable, so it will encounter the error when you attempt to set new value to this variable. You can try to set another different variable to store DB_Server_Name. Hope it can help. Best regards Patrick Zeng hw do i set the DB_Server_Name as the sql_enviroment? where is the WriteVariable method and how do i rewrite the values? please help.. Sorry i am very new to this..
November 5th, 2011 6:45am

Based on what I see you are only missing the Environment Variable DB_Server_Name. Its value needs to be set the proper SQL Server instance name. Do as No_Prakash said: "GO To Start -> MyComputer -> Right Click Properties -> Advanced -> Environment Variables". Inspect both text lists, the User variables, and the System Variables for name DB_Server_Name, if it is not there, then click New button at the bottom for the System Variables and add it as "Variable name", and its value below (the server name), then your package must run no problem.Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
November 6th, 2011 10:31pm

i shall try it out tomorrow..Thanks for the reply... is my codes correct? or is there any syntax error? Dim sql As String SetReportName() Try ' 1. Initial variables using all configured value for SSIS in database Using sqlConn As New Data.SqlClient.SqlConnection(sqlConnStr) sqlConn.Open() Using sqlCmd As New Data.SqlClient.SqlCommand(sql, sqlConn) is this code, in the last line, SqlCommand(sql,sqlConn), i do not know what i should put inside the bracket. if i remove the word sql, then there is red line appearing.
November 7th, 2011 12:59am

i have edited the enviromnet variables in my computer. after running the ssis, the error came out is Information: 0x40016038 at Cntr_Aging_Data_Dump: The package is attempting to configure from the environment variable "DB_Server_Name". SSIS package "Cntr_Aging_Data_Dump.dtsx" starting. Information: 0x4004300A at Data Dump, DTS.Pipeline: Validation phase is beginning. Error: 0x4 at Init Variables: The Script returned a failure result. Task failed: Init Variables Warning: 0x80019002 at Cntr_Aging_Data_Dump: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors. SSIS package "Cntr_Aging_Data_Dump.dtsx" finished: Failure. please help
Free Windows Admin Tool Kit Click here and download it now
November 7th, 2011 7:51pm

Hi noobie1, Please refer to the following links: http://dbaspot.com/ms-sqlserver/222243-passing-variables-script-task-help.html http://consultingblogs.emc.com/jamiethomson/archive/2008/08/19/ssis-validating-your-package-to-see-if-it-will-execute.aspx Thanks, Eileen
November 8th, 2011 3:29am

Hi noobie1, Please refer to the following links: http://dbaspot.com/ms-sqlserver/222243-passing-variables-script-task-help.html http://consultingblogs.emc.com/jamiethomson/archive/2008/08/19/ssis-validating-your-package-to-see-if-it-will-execute.aspx Thanks, Eileen
Free Windows Admin Tool Kit Click here and download it now
November 8th, 2011 11:27am

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

Other recent topics Other recent topics