查询数据库表的所有字段

using (OleDbConnection Conn = new OleDbConnection(Connect.Str))
{
Conn.Open();
System.Data.OleDb.OleDbCommand cmd = new OleDbCommand(sql, Conn);
System.Data.OleDb.OleDbDataReader reader = cmd.ExecuteReader();
reader.Read();
ed.WriteMessage("\n" + reader.FieldCount );
for (int i = 0; i <= reader.FieldCount - 1; i++)
{
ed.WriteMessage("\n" +reader.GetName(i)); //获取所有字段以后还要存到这里面
}

}

posted @ 2015-07-30 10:46  BurdeNing  阅读(283)  评论(0编辑  收藏  举报