/// <summary>
/// 名称:GetTableSchema
/// 参数:string sqlStr,查询语句
/// 功能:获得表结构
/// 返回值:DataSet
/// </summary>
public DataSet GetTableSchema(string sqlStr)
{
DataSet ds = new DataSet();
OleDbCommand cmd = new OleDbCommand(sqlStr,conn);
conn.Open();
OleDbDataReader read = cmd.ExecuteReader();
DataTable tb = read.GetSchemaTable();//注意这句话
ds.Tables.Add(tb);
read.Close();
conn.Close();
return ds;
}
GetTableSchema(string sqlStr)函数,获得表结构,详细代码如下:
转载于:https://www.cnblogs.com/niceboy/articles/525193.html