September 14, 2015 at 11:07 am
Hello,
I created a package , where i have a execute sql task , where i connect to db2 and run the DB2 storedprocedure and the "full set result" is stored in a variable called "result " of object type.
2) This "execute task" is connected to Script task , where I read this "rsult" variable " from execute task and write to a .csv file.
My error : the excute task runs fine and turns "green" but "script task" errors out "System.IO.IOException: The process cannot access the file 'D:\jj\JJ_Data_Extract_20150914103322732.csv' because it is being used by another process."
I am expecting that "even though " the execute task runs fine , it is not storing data to a variable , so when my script task runs , it creates file , but there is no data to write to a file , so it errors out.
Any thoughts on error?
Also is there a way to check / see data here?
September 14, 2015 at 11:12 am
How is D:\jj\JJ_Data_Extract_20150914103322732.csv related to what you are doing?
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
September 14, 2015 at 12:36 pm
Inside script task , I first create a text file to the path "D:\....csv"
my code in c#
public void Main()
{
// TODO: Add your code here
OleDbDataAdapter oleDA = new OleDbDataAdapter();
Dts.TaskResult = (int)ScriptResults.Success;
string path = @"D:\jj\jj_Data_Extract_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".csv";
if (Dts.TaskResult == 0)
{
if (!System.IO.File.Exists(path))
System.IO.File.Create(path);
DataTable dT = new DataTable();
try
{
//dT = Dts.Variables["User::Result"].Value as DataTable;
oleDA.Fill(dT, Dts.Variables["User::Result"].Value);
string Row = "";
for (int i = 0; i < dT.Rows.Count; i++)
{
for (int j = 0; j < dT.Columns.Count; j++)
{
Row += dT.Rows[j].ToString();
if (j != dT.Columns.Count - 1)
Row += ",";
}
Row += "";
}
System.IO.File.WriteAllText(path, Row);
}
catch (Exception Ex)
{
System.IO.File.WriteAllText(path, Ex.StackTrace + "" + Ex.Message);
}
}
}
September 14, 2015 at 1:11 pm
Have you considered implementing this as a standard data flow, with your DB2 query as source and the CSV file as destination? It would seem much easier, though maybe I am missing something.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
September 14, 2015 at 1:43 pm
The Data flow is not working , as the DB2 is a stored procedure with paramters.
September 14, 2015 at 1:52 pm
komal145 (9/14/2015)
The Data flow is not working , as the DB2 is a stored procedure with paramters.
I use stored procs with parameters all the time, but not with DB2. Is this specifically a DB2 limitation?
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
September 14, 2015 at 2:02 pm
Yes. But the execute sql task is working fine , runs good. But no idea if it is returning any data or not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply