protected void Page_Load(object sender, System.EventArgs e)
{
Data.DataTable DataTable1 = new Data.DataTable();
DataTable1.ReadXml("C:\\Data.xml");
string[] ColumnValues = DataTableColumnValuesToStringArray(DataTable1, "ColumnName");
}
public string[] DataTableColumnValuesToStringArray(Data.DataTable PassedDataTable, string PassedColumnName)
{
string[] functionReturnValue = null;
if ((PassedDataTable.Columns.Contains(PassedColumnName) == false) | (PassedDataTable.Rows.Count < 1)) {
return null;
return functionReturnValue;
}
string[] ReturnValues = new string[PassedDataTable.Rows.Count];
for (int i = 0; i <= PassedDataTable.Rows.Count - 1; i++) {
ReturnValues(i) = Convert.ToString(PassedDataTable.Rows(i).Item(PassedColumnName));
}
return ReturnValues;
return functionReturnValue;
}
Create an array from a column of data in a table
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment