设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

12下一页
返回列表 发新帖
查看: 1593|回复: 10
打印 上一主题 下一主题

[其它] 请教 表 删除后去哪了?能恢复吗??谢谢!!![color=#DC143C]加急!!!![/co

[复制链接]
跳转到指定楼层
1#
发表于 2004-1-2 21:38:00 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
????????谢谢
[em18]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
11#
发表于 2006-3-4 16:38:00 | 只看该作者
恢復刪除的工作表(未被壓縮)<RE><FONT size=3>ublic 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)



  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)



  '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)



  On Error GoTo ErrorHandler:



  Dim qDefOld As DAO.QueryDef

  Dim qDefNew As DAO.QueryDef

  Dim Field As DAO.Field



  Set qDefOld = dbDat
10#
发表于 2006-3-4 16:29:00 | 只看该作者
问题:













如何恢复已经删除的记录;如何恢复已经删除的表、窗体等等对象
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 的记录即可。
9#
发表于 2004-2-25 16:01:00 | 只看该作者

  又学了一招,为了我的习作。我前后建过不下40个窗体了……因为总出现错误值,我是说录入时,就删了重建。以后我会试试的:)
8#
发表于 2004-2-25 05:21:00 | 只看该作者
我也想知道,不知没有没这样的恢复工具
7#
发表于 2004-1-4 21:27:00 | 只看该作者
我以前看過tmtony所說的範例

点击这里给我发消息

6#
发表于 2004-1-3 06:16:00 | 只看该作者
如果是刚删除,未再进行过新建或修改表的操作,可在选项里,选择显示所有隐藏和系统表,看看有否~开头或其它开头的但不是系统表的表, 将其恢复看看
5#
 楼主| 发表于 2004-1-3 00:53:00 | 只看该作者
不是呀,
4#
发表于 2004-1-2 23:13:00 | 只看该作者
若刚删除,可点恢复按钮,来恢复。
3#
 楼主| 发表于 2004-1-2 22:33:00 | 只看该作者
啊?完了!谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2025-5-21 06:45 , Processed in 0.115613 second(s), 34 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表