Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Learning is a never ending thing and just one life is not enough to learn all the things you want to learn. The ocean of knowledge is very, very deep. This blog has been created for the same objective. I write on things which I come across in my daily life and feel to share it with the people across the world. The blog publish articles on SQL Server, SSIS 2005, SSIS 2008 alongwith other useful stuff which are good to know for the professional life.
Browse by Tags · View All
Google SpreadSheet API 12
YouTube API with .NET 7
PEGA Tutorials 6
PRPC Tutorials 6
Google BigQuery 6
Google Analytics API in .NET 6
Google Cloud Services 5
Core Reporting API with C# 4
Good Data API with Picasa 4
Ms-Excel function 4

Archive · View All
June 2012 17
October 2012 12
May 2012 12
August 2012 11
March 2013 10
July 2012 10
December 2011 9
January 2012 7
September 2012 6
February 2012 6

SinghVikash Blog

SSIS: How to read Excel Meta Data?

Jan 21 2012 12:00AM by Vikash Kumar Singh   

A lot of our learning comes from different forums we visits on daily or weekly basis. This post is also inspired by one of the popular forum which I recently visited and found a very interesting question on Ms-Excel and SSIS. The reader had asked how he can check in the Excel file, a particular column exist or not before processing the file with SSIS.

This made me to think what solution we can offer to this question. I did some finding with the Excel and BIDS and come out with one of the solution. I am sure there might be a better solution than this but I thought to share it get some more understanding. I would request you to leave some comments if you have a better solution or find this fine. So here goes my solution.

I have an Excel file which has data like this:

I want to check whether the Population column exists or not in the excel file. I created an Excel Connection Manager in my SSIS package which points to this excel file.

I added a Script Task on the control flow tab. I am using the System.Data.OleDb namespace to read the excel schema. I added following code snippet in my script task:

public void Main()
{
OleDbConnection myConn;
DataTable DT;
int blColExist;
blColExist = 0;
myConn = new OleDbConnection(Dts.Connections["ExcelManager"].ConnectionString.ToString());
myConn.Open();
DT = myConn.GetSchema("Columns");

/******************************
* Check the Column name
******************************/
foreach (DataRow DR in DT.Rows)
{
if (DR["Column_Name"].ToString() == "Population")
{
blColExist = 1;
}
}

if (blColExist.Equals(1))
{
System.Windows.Forms.MessageBox.Show("Population Column exist");
}
else
{
System.Windows.Forms.MessageBox.Show("Population Column DOES NOT exist");
}
}

As you see in the code I am reading the excel schema details about Columns. The column_name column return the name of each column in the excel file. I put an IF statement to check whether the “Population” column exist or not. After running the SSIS package I was greeted was this message box.

Wow!, the objective is met and I can check the columns existence. But I am know sure this is the only way. Let me ask it to the reader of this Post.


Republished from Blog by Vikash Kumar Singh [46 clicks].  Read the original version here [1 clicks].

Vikash Kumar Singh
279 · 0% · 152
3
 
0
Lifesaver
 
0
Refreshed
 
 
0
Incorrect



Submit

1  Comments  

  • This is the best approach to solve this. Though the code could be a bit modified. But apart from script task you cannot conclusively do this activity. There might be an option to use OpenRowQuery and select the column then use precedence on success anf failure to proceed, but this might fail for other reasons as well.

    Apart from these 2 methods I donot see any other way to proceed. Good Job!!

    commented on Mar 16 2012 4:24AM
    Sudeep Raj
    12 · 13% · 4287

Your Comment


Sign Up or Login to post a comment.

"SSIS: How to read Excel Meta Data?" rated 5 out of 5 by 3 readers
SSIS: How to read Excel Meta Data? , 5.0 out of 5 based on 3 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]