关闭顶部展开顶部

access下如何恢复已经删除的记录;如何恢复已经删除的表、窗体等等对象_Access数据库教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!
缂傚倸鍊搁崐鎼佸磹妞嬪海鐭嗗ù锝堫嚉濞差亝鏅濋柛灞炬皑閸旂數绱撴担鎻掍壕闂佺浜顤獵MS闂傚倷娴囧畷鐢稿窗閹扮増鍋¢柕澶堝剻濞戞ǚ鏀介悗锝冨妷閸嬫捇宕掗悙鏌ュ敹闂佸搫娲ㄩ崑鐐烘倵椤掆偓閳规垿鎮欓崣澶樻!闂佹悶鍔庨崰鏍ь嚕婵犳碍鏅搁柨鐕傛嫹濠电姷鏁搁崑鐐哄垂鐠轰警娼栭悷娆忓閻濆爼鏌涢埄鍐槈闁绘挻锕㈤弻鈥愁吋鎼粹€崇闂佹娊鏀辩敮锟犲蓟閵娾晜鍋嗛柛灞剧☉椤忥拷 缂傚倸鍊搁崐椋庣矆娓氣偓钘濋梺顒€绉寸粣妤呮煙闁箑澧鹃柤鏉挎健閺屾盯濡烽鐓庮潻缂備讲鍋撳鑸靛姈閻撳啴鏌曟径鍫濆闁绘繍浜弻锝呪攽閹炬潙顏� 闂傚倸鍊搁崐椋庢閿熺姴纾婚柛鏇ㄥ瀬閸ャ劍缍囬柍鍝勫暟椤︻垱绻濋姀锝嗙【闁哄牜鍓熷畷妤€饪伴崼鐔哄幐闂佹悶鍎崝宥夋儍閹达附鈷掑璺猴功鏁堥梺鍝勮閸婃牕岣胯箛娑樜╅柨鏃傜帛椤ユ稓绱撻崒娆戝妽闁哥偛顭烽獮蹇涙晸閿燂拷 闂傚倸鍊风粈渚€骞栭锕€鐤柣妤€鐗婇崣蹇涙煙缂併垹鏋涙俊鐐扮矙閺屸€愁吋鎼粹€茬敖闂佸憡顨嗙喊宥囨崲濞戙垹骞㈡俊顖濐嚙闂夊秴鈹戦鍡欑ɑ闁告梹顨婇崺鈧い鎺戝枤濞兼劙鏌熼鑲╁煟鐎规洘娲熼弻鍡楊吋閸涱垳鍘梻浣芥硶閸o箓骞忛敓锟�,闂傚倸鍊峰ù鍥儍椤愶箑绀嬫い鎰╁灩琚橀梻浣筋嚙濮橈箓锝炴径瀣濠电姴鍋嗛崵鏇㈡煕椤愶絾绀€缂佲偓閸愨斂浜滈柡鍌氱仢閹垶銇勮箛鏇炴瀾缂佺粯鐩獮瀣倷閺夋垹娈ら梻浣呵归鍡涘箲閸パ屾綎闁告繂瀚ч弸搴ㄦ煙椤栧棗瀚禍顏堟⒒娴e憡鍟為柣鐔村劤閹广垹螣娓氼垰娈ㄦ繝鐢靛У绾板秹寮查幖浣圭叆闁绘洖鍊圭€氾拷!

推荐:恢复从 Access 2000、 Access 2002 或 Access 2003 中数据库删除表的方法
恢复从 Access 2000、 Access 2002 或 Access 2003 中数据库删除表的方法

问题:

如何恢复已经删除的记录;如何恢复已经删除的表、窗体等等对象
1、我用 DELETE FROM TABLE 删除了一些记录,现在发现误删除了,该如何恢复?
2、我直接手动删除或者用 DROP TABLE 删除了一个表,现在发现是误删除了,该如何恢复?
3、我手动删除了一个窗体,该如何恢复?
4、我删除了记录,可是数据库体积并没有减小,那么是否能找回记录呢?




回答:

1、已经删除的记录是无法恢复的,ACCESS 不是 FOXPRO,MDB 格式不是 DBF 格式,没有逻辑删除和物理删除的概念,一旦删除就无法恢复了。
2、无法恢复,但是你可以查看一下,有没有隐藏的以 "~" 符号开头的表,更改该表的名称有可能找回你需要的表。
3、无法恢复,但是你可以查看一下有没有系统隐藏的对象,有时候对象被删除时系统并不直接删除,而是更改对象名后隐藏它。
4、数据库体积的确没有变小,你压缩修复数据库后体积就会变小了。那是因为在二进制上你的数据的确没有被删除,仍然存放在磁盘的某个扇区,但是微软没有提供 MDB 格式二进制组织方式的参考资料(微软也不会提供,其他第三方公司也没有权利直接反编译 MDB 格式)。至今为止,中国大陆我也没有看到过相关的参考资料。所以目前为止,你已经删除的数据是无法恢复的。但是你可以尝试使用磁盘恢复软件来找到恢复数据的方法,但是该方法不在本文讨论范围。

建议:在建立数据库结构时,可以在各个表中再多加一个 ISDEL 字段,删除记录时不使用 DELETE FROM ,而使用 UPDATE TABLE SET ISDEL=TRUE 这样的语句,然后在界面上不显示 ISDEL=TRUE 的记录即可。
复制代码 代码如下:www.mb5u.com

如果还没有被压缩理论上可以。试试这段代码吧。加在access模组中
恢復刪除的工作表(未被壓縮)
 
Public Function FnUndeleteObjects() As Boolean
On Error GoTo ErrorHandler:
Dim strObjectName As String
Dim rsTables As DAO.Recordset
Dim dbsDatabase As DAO.Database
Dim tDef As DAO.TableDef
Dim qDef As DAO.QueryDef
Dim intNumDeletedItemsFound As Integer
Set dbsDatabase = CurrentDb
For Each tDef In dbsDatabase.TableDefs
'This is actually used as a 'Deleted Flag'
If tDef.Attributes And dbHiddenObject Then
strObjectName = FnGetDeletedTableNameByProp(tDef.Name)
strObjectName = InputBox("A deleted TABLE has been found." & _
vbCrLf & vbCrLf & _
"To undelete this object, enter a new name:", _
"Access Undelete Table", strObjectName)

If Len(strObjectName) > 0 Then
FnUndeleteTable CurrentDb, tDef.Name, strObjectName
End If
intNumDeletedItemsFound = intNumDeletedItemsFound + 1
End If
Next tDef

For Each qDef In dbsDatabase.QueryDefs
'Note 'Attributes' flag is not exposed for QueryDef objects,
'We could look up the flag by using MSysObjects but
'new queries don't get written to MSysObjects until
'Access is closed. Therefore we'll just check the
'start of the name is '~TMPCLP' ...
If InStr(1, qDef.Name, "~TMPCLP") = 1 Then
strObjectName = ""
strObjectName = InputBox("A deleted QUERY has been found." & _
vbCrLf & vbCrLf & _
"To undelete this object, enter a new name:", _
"Access Undelete Query", strObjectName)

If Len(strObjectName) > 0 Then
If FnUndeleteQuery(CurrentDb, qDef.Name, strObjectName) Then
'We'll rename the deleted object since we've made a
'copy and won't be needing to re-undelete it.
'(To break the condition "~TMPCLP" in future...)
qDef.Name = "~TMPCLQ" & Right$(qDef.Name, Len(qDef.Name) - 7)
End If
End If
intNumDeletedItemsFound = intNumDeletedItemsFound + 1
End If
Next qDef
If intNumDeletedItemsFound = 0 Then
MsgBox "Unable to find any deleted tables/queries to undelete!"
End If

Set dbsDatabase = Nothing
FnUndeleteObjects = True
ExitFunction:
Exit Function
ErrorHandler:
MsgBox "Error occured in FnUndeleteObjects() - " & _
Err.Description & " (" & CStr(Err.Number) & ")"
GoTo ExitFunction
End Function


Private Function FnUndeleteTable(dbDatabase As DAO.Database, _
strDeletedTableName As String, _
strNewTableName As String)

'Module (c) 2005 Wayne Phillips (http://www.everythingaccess.com)
'Written 18/04/2005
Dim tDef As DAO.TableDef
Set tDef = dbDatabase.TableDefs(strDeletedTableName)
'Remove the Deleted Flag...
tDef.Attributes = tDef.Attributes And Not dbHiddenObject
'Rename the deleted object to the original or new name...
tDef.Name = strNewTableName
dbDatabase.TableDefs.Refresh
Application.RefreshDatabaseWindow
Set tDef = Nothing
End Function

Private Function FnUndeleteQuery(dbDatabase As DAO.Database, _
strDeletedQueryName As String, _
strNewQueryName As String)

'Module (c) 2005 Wayne Phillips (http://www.everythingaccess.com)
'Written 18/04/2005
'We can't just remove the Deleted flag on queries
'('Attributes' is not an exposed property)
'So instead we create a new query with the SQL...

'Note: Can't use DoCmd.CopyObject as it copies the dbHiddenObject attribute!

If FnCopyQuery(dbDatabase, strDeletedQueryName, strNewQueryName) Then
FnUndeleteQuery = True
Application.RefreshDatabaseWindow
End If
End Function


Private Function FnCopyQuery(dbDatabase As DAO.Database, _
strSourceName As String, _
strDestinationName As String)

'Module (c) 2005 Wayne Phillips (http://www.everythingaccess.com)
'Written 18/04/2005
On Error GoTo ErrorHandler:

Dim qDefOld As DAO.QueryDef
Dim qDefNew As DAO.QueryDef
Dim Field As DAO.Field

Set qDefOld = dbDatabase.QueryDefs(strSourceName)
Set qDefNew = dbDatabase.CreateQueryDef(strDestinationName, qDefOld.SQL)

'Copy root query properties...
FnCopyLvProperties qDefNew, qDefOld.Properties, qDefNew.Properties

For Each Field In qDefOld.Fields
'Copy each fields individual properties...
FnCopyLvProperties qDefNew.Fields(Field.Name), _
Field.Properties, _
qDefNew.Fields(Field.Name).Properties
Next Field
dbDatabase.QueryDefs.Refresh
FnCopyQuery = True
ExitFunction:
Set qDefNew = Nothing
Set qDefOld = Nothing
Exit Function
ErrorHandler:
MsgBox "Error re-creating query '" & strDestinationName & "':" & vbCrLf & _
Err.Description & " (" & CStr(Err.Number) & ")"
GoTo ExitFunction
End Function

Private Function PropExists(Props As DAO.Properties, strPropName As String) As Boolean
'Module (c) 2005 Wayne Phillips (http://www.everythingaccess.com)
'Written 18/04/2005
'If properties fail to be created, we'll just ignore the errors
On Error Resume Next
Dim Prop As DAO.Property
For Each Prop In Props
If Prop.Name = strPropName Then
PropExists = True
Exit Function ' Short circuit
End If
Next Prop
PropExists = False
End Function

Private Sub FnCopyLvProperties(objObject As Object, OldProps As DAO.Properties, NewProps As DAO.Properties)
'Module (c) 2005 Wayne Phillips (http://www.everythingaccess.com)
'Written 18/04/2005
'If properties fail to be created, we'll just ignore the errors
On Error Resume Next
Dim Prop As DAO.Property
Dim NewProp As DAO.Property
For Each Prop In OldProps
If Not PropExists(NewProps, Prop.Name) Then
If IsNumeric(Prop.Value) Then
NewProps.Append objObject.CreateProperty(Prop.Name, Prop.Type, CLng(Prop.Value))
Else
NewProps.Append objObject.CreateProperty(Prop.Name, Prop.Type, Prop.Value)
End If
Else
With NewProps(Prop.Name)
.Type = Prop.Type
.Value = Prop.Value
End With
End If
Next Prop
End Sub

Private Function FnGetDeletedTableNameByProp(strRealTableName As String) As String
'Module (c) 2005 Wayne Phillips (http://www.everythingaccess.com)
'Written 18/04/2005
'If an error occurs here, just ignore (user will override the blank name)
On Error Resume Next
Dim i As Long
Dim strNameMap As String

'Look up the Unicode translation NameMap property to try to guess the
'original table name... (Access 2000+ only - and doesn't always exist?!)

strNameMap = CurrentDb.TableDefs(strRealTableName).Properties("NameMap")
strNameMap = Mid(strNameMap, 23) 'Offset of the table name...

'Find the null terminator...
i = 1
If Len(strNameMap) > 0 Then
While (i < Len(strNameMap)) And (Asc(Mid(strNameMap, i)) <> 0)
i = i + 1
Wend
End If
FnGetDeletedTableNameByProp = Left(strNameMap, i - 1)
End Function

分享:ACCESS的参数化查询,附VBSCRIPT(ASP)和C#(ASP.NET)函数
ACCESS的参数化查询,附VBSCRIPT(ASP)和C#(ASP.NET)函数

来源:模板无忧//所属分类:Access数据库教程/更新时间:2013-04-22
相关Access数据库教程
闂備焦鐪归崺鍕垂闁秵鍋ら柡鍥舵緛缂嶆牠鏌涢埄鍐姇闁抽攱甯楅妵鍕即濡も偓娴滄儳顪冮妶蹇曠Ф闁瑰嚖鎷�
婵犵數鍋涢顓熸叏椤撱垹纾婚柟鐐灱濡插牓鏌¢崒婵囩《濠⒀勭⊕娣囧﹪鎳犻澶嗗亾濠靛鐓熼柕蹇婃櫅閻忔煡鏌熼崙銈嗗
婵犵數濮烽。浠嬪焵椤掆偓閸熷潡鍩€椤掑嫷妫戠紒杈╁仜椤撳吋寰勭€n亝顓鹃柣搴f嚀鐎氼厽绔熼崱娆愬床濞戞柧绶氶弻锝夊閳轰胶浼堥梺鐟板殩閹凤拷
婵犵數濮烽。浠嬪焵椤掆偓閸熷潡鍩€椤掑嫷妫戠紒杈╁仜椤撳吋寰勬繝鍕靛悑闂備浇顕栭崹搴ㄥ礋椤撗勑氶梻浣筋嚙闁帮絽岣胯铻炴繛鎴欏灪閸嬪鏌ㄩ悤鍌涘
闂傚倷鑳舵灙缂佺粯鍔欓獮濠冩償閵娿儳鍔﹀銈嗗笒閸婂摜鏁崼鏇炵閻庢稒岣块惌鎺斺偓瑙勬礃缁诲牓寮幘缁樻櫢闁跨噦鎷�
闂傚倷鑳舵灙缂佺粯鍔欓獮濠冩償閵娿儳鍔﹀銈嗗坊閸嬫捇鏌涘顒夊剳缂侇喖锕弫鍌炲礈瑜忛悡鎾绘煟鎼搭垳宀涢柡鍛箞閹苯鈻庨幋鐘碉紳婵炴挻鑹鹃敃銉р偓姘炬嫹
闂傚倷娴囬妴鈧柛瀣尰閵囧嫰寮介妸褉妲堥梺浼欏瘜閸o綁寮诲☉妯锋斀闁归偊浜為懗铏圭磽娴i潧濡芥俊鐐舵椤曪綁濡搁埡濠冩櫖濠电偛妫欓崹鐢电箔閿熺姵鈷戦柛婵嗗閳ь剙顭烽獮濠囧箻閼告娼熼梺璺ㄥ櫐閹凤拷
闂傚倷绀侀幖顐﹀疮閻楀牊鍙忓瀣捣缁€濠傤熆閼搁潧濮堥柣鎿勭秮閹娼幏宀婂妳濠电偛鐪伴崐鏇㈡箒闂佹寧绻傚Λ娆戠矆閳ь剟姊洪崨濞氭垿鎮ч悩鑼殾闁规壆澧楅弲鎼佹煥閻曞倹瀚�
濠电姷顣藉Σ鍛村垂椤忓牆绀堟繝闈涙-閻斿棙淇婇姘倯閻庢氨绮妵鍕箻鐎靛摜鐣洪柣搴㈢啲閹凤拷
婵犵數濮烽。浠嬪焵椤掆偓閸熷潡鍩€椤掑嫷妫戠紒杈╁仜椤撳ジ宕堕妸銉紩婵$偑鍊栭幐鑽ゆ崲閸愵亖鍋撳铏彧濞e洤锕、娑樜旈埀顒佹櫠閸欏绡€妞ゎ偒鍠楃€氾拷
濠电姷顣藉Σ鍛村垂椤忓牆绀堟繝闈涙-閻斿棙鎱ㄥ璇蹭壕閻庤娲﹂崜鐔笺€佸▎鎾崇闁绘挸绨堕崑鎾绘偨閸涘﹦鍘搁梺鍓插亝缁诲嫬鐡┑鐘愁問閸n垶骞忛敓锟�
濠电姷顣藉Σ鍛村垂椤忓牆绀堟繝闈涙-閻斿棙鎱ㄥ璇蹭壕闂佸搫鑻幊姗€宕洪埀顒併亜閹哄棗浜鹃梺瀹狀嚙闁帮綁鐛幋锕€绠涢梻鍫熺⊕椤斿棝姊绘担鍛婃儓閻庢碍鎮傞獮蹇涙晸閿燂拷
濠电姷顣藉Σ鍛村垂椤忓牆绀堟繝闈涙-閻斿棙鎱ㄥ璇蹭壕閻庤娲╃紞渚€鐛€n亖鏀介柛顐亗缁憋拷
婵犵數濮烽。浠嬪焵椤掆偓閸熷潡鍩€椤掑嫷妫戠紒杈╁仜椤撳吋寰勬繝鍕幀闂備胶鎳撻悺銊ф崲閸曨垼鏁傞悗娑櫭肩换鍡樸亜閺嶎煈娈斿褍寮剁换婵嬶綖椤旇棄顏�
闂備浇顕ф鎼佸储濠婂牆绀堟繝闈涱儐閸嬪鏌熼幆鐗堫棄闁活厽顨呴埞鎴︽偐閹绘帗娈梺濂告涧缂嶅﹪寮婚妶澶嬪殟闁靛鍎遍~宥夋⒑缂佹ḿ澹勭紓宥勭閻e嘲鈻庨幘瀛樻闂佽法鍣﹂幏锟�
UB闂傚倷绀佸﹢杈╁垝椤栫偛绀夋俊銈呮噽瀹撲線鏌涢妷銏℃珕閻庢碍宀搁幃妤€鈽夊▍铏灴閿濈偤鏁撻敓锟�
闂傚倷娴囨竟鍫熴仈缁嬫娼栧┑鐘崇閻掗箖鎮楅悽鐢点€婇柛瀣崌閻涱噣宕归鍙ョ棯婵犵數濮崑鎾绘煥閻曞倹瀚�
闂備浇顕ф鍝ョ不瀹ュ鍨傞柛婵嗗閼板潡鏌涢姀銏犳
闂傚倷绀侀幉鈥愁潖缂佹ɑ鍙忓瀣捣缁€濠傤熆鐠鸿櫣鐏遍柛妤佺缁绘盯宕卞Δ鈧銏ゆ煕閻愬樊妲圭紒缁樼〒缁辨瑩鎮╅崫鍕腐闂備胶枪妤犲繘骞忛敓锟�
缂傚倸鍊搁崐鐑芥倿閿曞倹鍋¢柨鏇炲€搁崹鍌涚節婵犲倸顏い鈺呮敱閵囧嫰骞掑鍥舵М缂備焦褰冨﹢閬嶅焵椤掑倸浠柛濠冪箘缁辨挸顫濇0婵囨櫓闂佽法鍣﹂幏锟�
©2017 www.mb5u.com濠电姷顣藉Σ鍛村垂椤忓牆绀堟繝闈涙-閻斿棙鎱ㄥ璇蹭壕閻庢鍣崳锝夊箖閳哄懎绠甸柟鐑樻尭閻︼拷
闂傚倷娴囬妴鈧柛瀣崌閺岀喖顢涘⿰鍐炬毉濡炪們鍎婚幏锟�&闂傚倷绀侀幉锛勬暜閹烘嚦娑㈠籍閸噥妫呴梺璺ㄥ櫐閹凤拷