string data = string.Empty;
DataTable OutDataTable = new DataTable();
OracleDataReader daReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
OutDataTable = new DataTable();
DataRow dataRow;
//设置Table名和Column名
OutDataTable.TableName ="test";
for (int j = ; j < daReader.FieldCount; j++)
{
//获取列名
OutDataTable.Columns.Add(daReader.GetName(j));
}
//循环取数据集合中的数据,存到DataTable中
do
{
while (daReader.Read())
{
dataRow = OutDataTable.NewRow();
for (int j = ; j < daReader.FieldCount; j++)
{
data = daReader[j].ToString();
dataRow[j] = data;
}
OutDataTable.Rows.Add(dataRow);
}
} while (daReader.NextResult());
dtTemp = OutDataTable;
手机扫一扫
移动阅读更方便
你可能感兴趣的文章