国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

恢復(fù)從 Access 2000、 Access 2002 或 Access 2003 中數(shù)據(jù)庫刪除表的方法

瀏覽:211日期:2023-03-18 16:41:51
 注意 : 本文示例代碼使用 Microsoft 數(shù)據(jù)訪問對象。 為此代碼才能正常運行, 您必須引用 Microsoft DAO 3.6 對象庫。 可以進行, 單擊  工具  菜單中 VisualBasic 編輯器, 上  引用  并確保選中  Microsoft DAO 3.6 對象庫  復(fù)選框。

1.    在 MicrosoftAccess 中打開數(shù)據(jù)庫。
2.    在數(shù)據(jù)庫窗口, 單擊下 對象 , 模塊 , 然后單擊 新建 。
3.    鍵入或粘貼以下代碼, 您只有創(chuàng)建模塊中: 

復(fù)制代碼 代碼如下:
Function RecoverDeletedTable() 
On Error GoTo ExitHere 

"*Declarations* 
  Dim db As DAO.Database 
  Dim strTableName As String 
  Dim strSQL As String 
  Dim intCount As Integer 
  Dim blnRestored As Boolean 

"*Init* 
  Set db = CurrentDb() 

"*Procedure* 
  For intCount = 0 To db.TableDefs.Count - 1 
    strTableName = db.TableDefs(intCount).Name 
    If Left(strTableName, 4) = "~tmp" Then 
      strSQL = "SELECT DISTINCTROW [" & strTableName & "].* INTO " & Mid(strTableName, 5) & " FROM [" & strTableName & "];" 
      DoCmd.SetWarnings False 
      DoCmd.RunSQL strSQL 
      MsgBox "A deleted table has been restored, using the name "" & Mid(strTableName, 5) & """, vbOKOnly, "Restored" 
      blnRestored = True 
    End If 
  Next intCount 

  If blnRestored = False Then 
MsgBox "No recoverable tables found", vbOKOnly 
  End If 

"*EXIT/ERROR* 
ExitHere: 
  DoCmd.SetWarnings True 
  Set db = Nothing 
  Exit Function 

ErrorHandler: 
  MsgBox Err.Description 
  Resume ExitHere 

End Function


4.    在 調(diào)試 菜單上, 單擊 編譯 數(shù)據(jù)庫名稱 數(shù)據(jù)庫名稱 。
5.    保存為 RecoverTable 模塊。 要測試此函數(shù), 首先創(chuàng)建兩個表, 添加行, 并刪除這兩個表。
6.    在即時窗口, 鍵入以下行, 然后按 ENTER 鍵:

RecoverDeletedTable
標(biāo)簽: Access
相關(guān)文章:
主站蜘蛛池模板: 额济纳旗| 普安县| 鞍山市| 尖扎县| 察隅县| 临城县| 柘城县| 大连市| 南川市| 郎溪县| 巴彦县| 壤塘县| 闵行区| 府谷县| 高密市| 雅江县| 德令哈市| 焦作市| 灵台县| 宜兰市| 文山县| 韩城市| 济南市| 民权县| 和平区| 南华县| 栾川县| 涿鹿县| 普陀区| 浪卡子县| 来宾市| 扎兰屯市| 神池县| 黄平县| 河西区| 上虞市| 资阳市| 永宁县| 兴业县| 谢通门县| 子洲县|