Asp.net获取Access中现有表名

80酷酷网    80kuku.com

  access|asp.net

 protected void GetTable()
    {
        object[] restrictions = new object[] { null, null, null, "TABLE" }; //
        OleDbConnection getTableConn = new OleDbConnection(CgetConnStr.connString);
        getTableConn.Open();
        DataTable tempTable = getTableConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,restrictions);
        ArrayList TableName = new ArrayList();
        int count = tempTable.Rows.Count;
        for (int i = 0; i < count; i++)
        {
            TableName.Add(tempTable.Rows[i]["TABLE_NAME"].ToString());
            TextBox tempTb = new TextBox();
            tempTb.ID = "tb" + i.ToString();
            tempTb.Text = (string)TableName[i];
            this.Controls.Add(tempTb);
        }
        getTableConn.Close();
    }

    public override void VerifyRenderingInServerForm(Control control)
    {
    }

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: