Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Datatable column to array
 

Datatable column to array

Hi

I have a datatable with four column, and need read one of these columns, and put these contents in a string array. I have read this post:
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/00030777-82cc-40d7-811d-d35c5e8826a3

but can not complete the operation.

private void manager_Load(object sender, EventArgs e)

        {           

            this.usersTableAdapter.Fill(this.reportDataSet.Users);

            DataRow[] dr = new DataRow[this.reportDataSet.Users.Rows.Count];

            this.reportDataSet.Users.Rows.CopyTo(dr, 0);

            string[] usr = Array.ConvertAll(dr, new Converter<DataRow,String>((DataRow)ToString()));

        }



I using VS 2008 and C#, so can not write correct code(last line) and can notreceive needed string array.
please, help

Mirage_sk  Saturday, October 03, 2009 11:22 AM
DataRow[] rows = this.reportDataSet.Users.Select();
string[] stringArray = rows.Select(row => row["columnName"].ToString()).ToArray();
  • Marked As Answer byMirage_sk Monday, October 05, 2009 1:17 PM
  •  
Wole Ogunremi  Saturday, October 03, 2009 12:03 PM
DataRow[] rows = this.reportDataSet.Users.Select();
string[] stringArray = rows.Select(row => row["columnName"].ToString()).ToArray();
  • Marked As Answer byMirage_sk Monday, October 05, 2009 1:17 PM
  •  
Wole Ogunremi  Saturday, October 03, 2009 12:03 PM
Thanks, man! Great!
Mirage_sk  Monday, October 05, 2009 1:17 PM

You can use google to search for other answers

Custom Search

More Threads

• Datagridview KeyDown Event
• drag and drop the nodes of a tree view using ado.net in c#
• Datagridview orientation
• Images don't display.
• Datagridview binding to 2 sources
• listbox selected index changed
• Typed dataset and transaction question
• Show data from ms access in a textBox
• How to read all files selected with an OpenFileDiaglog?
• XML Reading speed question