views:

35

answers:

2

How to get a DataTable from DataRow[] collection ?

I tried the following conversion , but it returns null.

    string ProcessQuery(ref DataRow[] rows)
            {
                DataTable _tb = new DataTable();

                foreach (DataRow _dr in rows)
                {
                    _tb.Rows.Add(_dr); 
                }
                _tb.AcceptChanges(); 
...
...
           }

Request your help.

A: 

should it not be _tb.importRow()?

Dean
A: 

Each dataRow has a Table property, So if you have the datarows DataRow[] just pick any row and go:

rows[0].Table

string ProcessQuery(ref DataRow[] rows) 
        { 
            DataTable _tb = rows[0].Table; 
            // other stuff
       } 
Charles Bretana