Hi,
I have some data which I get by running Execute Sql Task ,and I populate this in a object called "ResultTest".So my main aim is to check that if there something in Object then Mail it else leave it.
Below is the steps which I performed but no luck in getting proper output.
1. I have a Object called "ResultSet where I store the value"
2. I use Script task where I use this object ,and try to read the object and pass it into various variable(no.of columns) of type object .
3.Suppose I have data in object like this
Now I want to Read the data and pass the values each column into variable
For Example I have created TimeDifferenceTotal Object so I want to add in values 314,313 and similarly other columns also.
public void Main()
{
DataTable dtTotal = new DataTable();
OleDbDataAdapter adapter = new OleDbDataAdapter();
DataTable dt = new DataTable();
adapter.Fill(dt, Dts.Variables["ResultSet"].Value);
// In the first Run dtTotal is created
if (Dts.Variables["ApplicationNameFinal"].Equals(""))
{
foreach (DataColumn dc in dt.Columns)
{
dtTotal.Columns.Add(dc.ColumnName, dc.DataType);
}
}
else // In the next runs dtTotal is retrieved from variable
{
dtTotal = (DataTable)Dts.Variables["TimeDifferenecTotal"].Value;
dtTotal = (DataTable)Dts.Variables["UpdateTime"].Value;
dtTotal = (DataTable)Dts.Variables["ApplicationNameFinal"].Value;
dtTotal = (DataTable)Dts.Variables["ServernameFinal"].Value;
dtTotal = (DataTable)Dts.Variables["DatabaseNameFinal"].Value;
}
foreach (DataRow dr in dt.Rows)
{
DataRow newDR = dtTotal.NewRow();
foreach (DataColumn dc in dt.Columns)
{
newDR[dc.ColumnName] = dr[dc.ColumnName];
}
dtTotal.Rows.Add(newDR);
}
Dts.Variables["TimeDifferenecTotal"].Value = dtTotal.Columns[0];
Dts.Variables["UpdateTime"].Value = dtTotal.Columns[1];
Dts.Variables["ApplicationNameFinal"].Value = dtTotal.Columns[2];
Dts.Variables["ServernameFinal"].Value = dtTotal.Columns[3];
Dts.Variables["DatabaseNameFinal"].Value = dtTotal.Columns[4];
}