/// <summary>
/// 将ITable转换为DataTable
/// </summary>
/// <param name="mTable"></param>
/// <returns></returns>
public static DataTable ToDataTable(ITable mTable)
{
try
{
DataTable pTable = new DataTable();
for (int i = 0; i < mTable.Fields.FieldCount; i++)
{
pTable.Columns.Add(mTable.Fields.get_Field(i).Name);
}
ICursor pCursor = mTable.Search(null, false);
IRow pRrow = pCursor.NextRow();
while (pRrow != null)
{
DataRow pRow = pTable.NewRow();
string[] StrRow = new string[pRrow.Fields.FieldCount];
for (int i = 0; i < pRrow.Fields.FieldCount; i++)
{
StrRow[i] = pRrow.get_Value(i).ToString();
}
pRow.ItemArray = StrRow;
pTable.Rows.Add(pRow);
pRrow = pCursor.NextRow();
}
return pTable;
}
catch (Exception ex)
{
return null;
}
}
将ITable转换为DataTable
最新推荐文章于 2022-02-10 16:05:00 发布