恢復(fù)從 Access 2000、 Access 2002 或 Access 2003 中數(shù)據(jù)庫刪除表的方法
更新時間:2007年08月01日 19:28:24 作者:
注意 : 本文示例代碼使用 Microsoft 數(shù)據(jù)訪問對象。 為此代碼才能正常運行, 您必須引用 Microsoft DAO 3.6 對象庫。 可以進(jìn)行, 單擊 工具 菜單中 VisualBasic 編輯器, 上 引用 并確保選中 Microsoft DAO 3.6 對象庫 復(fù)選框。
1. 在 MicrosoftAccess 中打開數(shù)據(jù)庫。
2. 在數(shù)據(jù)庫窗口, 單擊下 對象 , 模塊 , 然后單擊 新建 。
3. 鍵入或粘貼以下代碼, 您只有創(chuàng)建模塊中:
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
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
相關(guān)文章
中文Access2000速成教程--1.3 在“設(shè)計”視圖中設(shè)計表
中文Access2000速成教程--1.3 在“設(shè)計”視圖中設(shè)計表...2006-11-11
Access數(shù)據(jù)中的SQL偏移注入原理解析
目標(biāo)數(shù)據(jù)表的字段較多,無法一一獲取的時候,嘗試使用偏移注入的方式實現(xiàn)SQL注入,這篇文章主要介紹了Access數(shù)據(jù)中的SQL偏移注入原理解析,感興趣的朋友跟隨小編一起看看吧2024-06-06
ACCESS 調(diào)用后臺存儲過程的實現(xiàn)方法
ACCESS是一個Client/Server的優(yōu)秀前端開發(fā)工具,具有易學(xué)易用,界面友好,開發(fā)簡單,和其他數(shù)據(jù)庫接口靈活。2009-03-03
中文Access2000速成教程--1.2 使用“數(shù)據(jù)庫向?qū)А眲?chuàng)建表
中文Access2000速成教程--1.2 使用“數(shù)據(jù)庫向?qū)А眲?chuàng)建表...2006-11-11
Access創(chuàng)建一個簡單MIS管理系統(tǒng)
所謂MIS管理系統(tǒng),是一個由人、計算機及其他外圍設(shè)備等組成的能進(jìn)行信息的收集、傳遞、存貯、加工、維護(hù)和使用的系統(tǒng)。MIS管理系統(tǒng)是一種新興的技術(shù),那么下文中就給大家介紹Access這個有歷史的數(shù)據(jù)庫系統(tǒng)如何創(chuàng)建一個簡單的MIS管理系統(tǒng)。2015-09-09

