convert string array to datarow array
How can i convert string array to an array of datarow can any one help me please.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Apr 12, 2011, 6:26 AM
// 'strings' is the string array and 'table' is the DataTable
DataRow[] rows = new DataRow[strings.Length];
for(int i = 0; i < strings.Length; i++)
{
rows[i] = table.NewRow();
// assuming each element of the string array contains comma-separated row values
rows[i].ItemArray = strings[i].Split(',');
table.Rows.Add(rows[i]); // if needed at this stage
}