Wrox Programmer Forums
|
BOOK: Microsoft SQL Server 2008 Integration Services Problem-Design-Solution
This is the forum to discuss the Wrox book Microsoft SQL Server 2008 Integration Services Problem-Design-Solution by Erik Veerman, Jessica M. Moss, Brian Knight, Jay Hackney ; ISBN: 978-0-470-52576-0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Microsoft SQL Server 2008 Integration Services Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 28th, 2010, 05:21 PM
Registered User
 
Join Date: Aug 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help converting VB.NET script to C# from Ch 5

What is the c# equivalent of the following code from Chapter 5, page 162?
Thanks

Code:
        ' get columns
        Dim dt As DataTable = CType(Dts.Variables("SourceColumns").Value, DataSet).Tables(0)
        Dim SourceColumns As List(Of String) = New List(Of String)
        For Each dr As DataRow In dt.Rows
            SourceColumns.Add(dr(0))
        Next
 
Old August 28th, 2010, 06:34 PM
Registered User
 
Join Date: Aug 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think I figured it out, the following does work, not sure if it is the most efficient way to do it.
Thanks

Code:
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            ds = Dts.Variables["SourceColumns"].Value as DataSet;
            dt = ds.Tables[0];

            List<string> sourceColumns = new List<string>();
            foreach (DataRow dr in dt.Rows)
            {
                sourceColumns.Add(dr[0].ToString());
            }
 
Old January 5th, 2011, 10:12 PM
Registered User
 
Join Date: Jan 2011
Posts: 8
Thanks: 0
Thanked 1 Time in 1 Post
Default

DataTable dt = ((DataSet)Dts.Variables("SourceColumns").Value).Ta bles(0);
List<string> SourceColumns = new List<string>();
foreach (DataRow dr in dt.Rows) {
SourceColumns.Add(dr(0));
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
help, converting vb.net few lines to C# nesrine C# 3 March 6th, 2007 10:43 AM
Problem Converting C# to VB.NET in ASP.NET kwilliams ASP.NET 2.0 Basics 0 February 9th, 2007 06:22 PM
Converting C# to VB.net ninel General .NET 0 August 11th, 2006 12:36 PM
converting code from c# to VB.net drachx General .NET 0 October 20th, 2004 11:19 PM
converting DTS package from VB 6 to VB .NET petroleo Pro VB Databases 0 August 18th, 2003 05:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.