I am using webservice method in one of my task and passing few variables as shown in image 1. priceIds is an int array as shown.
I have defined one variable as Object variable "Var_Array" and passing it to priceIds.To populate values in Var_Array variable i have first defined a string variable Var_Ws_Prd_name and stored values 2070,2071,2008,2009. (as shown in Image 2)
Then i saved values of Var_Ws_Prd_name into Var_Array using below code.
string a = Dts.Variables["User::Var_Ws_Prd_name"].Value.ToString();
int[] array = Array.ConvertAll(a.Split(','), int.Parse);
Dts.Variables["User::Var_Array"].Value = array;
This works fine.
Now instead of Var_Ws_Prd_name, we are putting values in Excel sheet as shown in Image 3. We have to read the values from excel sheet and put it into Var_Array. How can we do this using vb.net or C#. I wrote the below code in vb.net but its not working.
'This contains the path of excel sheet.
Dim Var_Masterfile As String
Var_Masterfile = Dts.Variables("User::Var_Masterfile").Value.ToString
Dim Var_Schedule As String
Var_Schedule = Dts.Variables("User::Var_Schedule").Value.ToString
Dim sConnectionString As String
sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Var_Masterfile & ";Extended Properties=Excel 8.0;"
Dim objConn As New System.Data.OleDb.OleDbConnection(sConnectionString)
objConn.Open()
Dim objCmd As New System.Data.OleDb.OleDbCommand("SELECT IHSCode FROM [master$] where IHSFlag ='Y' and Schedule='" & Var_Schedule & "'", objConn)
Dim objReader As System.Data.OleDb.OleDbDataReader
objReader = objCmd.ExecuteReader()
Dim al As New ArrayList
If objReader.HasRows.ToString = "True" Then
While objReader.Read()
al.Add(objReader.GetValue(0).ToString)
End While
End If
Dim array() As Object = al.ToArray()
Dts.Variables("Var_Array").Value = array
I got the below error when i run my SSIS job.
[Web Service Task] Error: An error occurred with the following error message: "Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebserviceTaskException: Could not execute the Web method. The error is: Method 'ProxyNamespace.Price.GetPricesData' not found..
at Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebMethodInvokerProxy.InvokeMethod(DTSWebMethodInfo methodInfo, String serviceName, Object connection)
at Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebServiceTaskUtil.Invoke(DTSWebMethodInfo methodInfo, String serviceName, Object connection, VariableDispenser taskVariableDispenser)
at Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebServiceTask.executeThread()".