"Read table schema by SqlDataReader" in this weblog,
http://iborn2code.blogspot.com/2009/04/c-adonet-how-to-get-table-schema.html
now the following code shows how to use the
table schema to generate a DataTable based on
the schema:
DataTable retDtaTbl = new DataTable();
if (tblSchema.Rows.Count == 0)
return retDtaTbl;
tblSchema.DefaultView.Sort = "ColumnOrdinal";
foreach (DataRow rowSchema in tblSchema.Rows)
retDtaTbl.Columns.Add(
rowSchema["ColumnName"].ToString(),
System.Type.GetType( rowSchema["DataType"].ToString() ) );
No comments:
Post a Comment