恢復(fù)從 Access 2000、 Access 2002 或 Access 2003 中數(shù)據(jù)庫(kù)刪除表的方法
更新時(shí)間:2007年08月01日 19:28:24 作者:
注意 : 本文示例代碼使用 Microsoft 數(shù)據(jù)訪問對(duì)象。 為此代碼才能正常運(yùn)行, 您必須引用 Microsoft DAO 3.6 對(duì)象庫(kù)。 可以進(jìn)行, 單擊 工具 菜單中 VisualBasic 編輯器, 上 引用 并確保選中 Microsoft DAO 3.6 對(duì)象庫(kù) 復(fù)選框。
1. 在 MicrosoftAccess 中打開數(shù)據(jù)庫(kù)。
2. 在數(shù)據(jù)庫(kù)窗口, 單擊下 對(duì)象 , 模塊 , 然后單擊 新建 。
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ù)庫(kù)名稱 數(shù)據(jù)庫(kù)名稱 。
5. 保存為 RecoverTable 模塊。 要測(cè)試此函數(shù), 首先創(chuàng)建兩個(gè)表, 添加行, 并刪除這兩個(gè)表。
6. 在即時(shí)窗口, 鍵入以下行, 然后按 ENTER 鍵:
RecoverDeletedTable
1. 在 MicrosoftAccess 中打開數(shù)據(jù)庫(kù)。
2. 在數(shù)據(jù)庫(kù)窗口, 單擊下 對(duì)象 , 模塊 , 然后單擊 新建 。
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ù)庫(kù)名稱 數(shù)據(jù)庫(kù)名稱 。
5. 保存為 RecoverTable 模塊。 要測(cè)試此函數(shù), 首先創(chuàng)建兩個(gè)表, 添加行, 并刪除這兩個(gè)表。
6. 在即時(shí)窗口, 鍵入以下行, 然后按 ENTER 鍵:
RecoverDeletedTable
相關(guān)文章
中文Access2000速成教程--1.1 使用“向?qū)А痹O(shè)計(jì)數(shù)據(jù)庫(kù)
中文Access2000速成教程--1.1 使用“向?qū)А痹O(shè)計(jì)數(shù)據(jù)庫(kù)...2006-11-11長(zhǎng)期使用中型Access數(shù)據(jù)庫(kù)的一點(diǎn)經(jīng)驗(yàn)與缺點(diǎn)
長(zhǎng)期使用中型Access數(shù)據(jù)庫(kù)的一點(diǎn)經(jīng)驗(yàn)與缺點(diǎn)...2007-07-07Access轉(zhuǎn)Sql Server問題 實(shí)例說明
對(duì)于網(wǎng)上的一些access轉(zhuǎn)sqlserver的解決方法,比較多,其實(shí)只要多注意,多實(shí)踐,發(fā)現(xiàn)問題,解決問題。2009-06-06union這個(gè)連接是有什么用的和INNER JOIN有什么區(qū)別
union這個(gè)連接是有什么用的和INNER JOIN有什么區(qū)別...2006-07-07Access出現(xiàn)"所有記錄中均未找到搜索關(guān)鍵字"的錯(cuò)誤解決
asp寫了那么長(zhǎng)時(shí)間都沒有發(fā)現(xiàn),今天居然讓我碰到了。 網(wǎng)頁(yè)頁(yè)面是一個(gè)標(biāo)題和信息內(nèi)容(備注型)的修改提交,第一次提交修改沒有問題,第二次提交修改就出現(xiàn)錯(cuò)誤2008-11-11