Converting a resultset variable to an array
I am using SSIS (VS 2008) and I want to take a populated resultset variable (populated from an EXECUTE SQL task) and convert within an SSIS Script Component (c#) it into an array.
The resultset contains a single column.
What would be the code to do this?
Edit: This is for a backfilling exercise; in normal circumstances, a web app calls a proc on the db that开发者_开发技巧 passes in a text string and gets a list of matching words based on this kind of query:
SELECT [Term]
FROM [dbo].[ATableOFTerms] WITH ( NOLOCK )
WHERE CHARINDEX(' ' + Term + ' ', @StringBeingSearched) > 0
Once the web app gets this list, it has a lot of business rules around what it converts it to but essentially it takes the list of matching terms and generates a single string that is then used for passing into a fulltext search.
The backfilling process in SSIS needs to mimic that so the script component has the same web app code that deals with the business logic but I needed c# code that does the above. Which is fine, I am returning all the [ATableTerms] into a resultset variable but now I need populate an array from the variable.
When I have this I can use string.Contains to achieve the same result.
IndexOf(term, StringComparison.OrdinalIgnoreCase) >= 0This is how it was solved, although I'd love to get an alternative to this.
OleDbDataAdapter adapter = new OleDbDataAdapter();
string Title = " " + Row.Title + " ";
DataTable dt = new DataTable();
adapter.Fill(dt , Variables.ATableOfTerms);
ArrayList terms = new ArrayList();
ArrayList returnedTerms = new ArrayList();
foreach (DataRow dr in dt.Rows)
{
terms.Add(" " + dr["Term"] + " ");
}
foreach (string term in terms)
{
if (Title.IndexOf(term, StringComparison.OrdinalIgnoreCase) >= 0)
{
returnedTerms.Add(term.Trim());
}
}
精彩评论