📄 viewtree.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
Caption = "内部数据库浏览"
ClientHeight = 5430
ClientLeft = 60
ClientTop = 345
ClientWidth = 5070
LinkTopic = "Form1"
LockControls = -1 'True
ScaleHeight = 5430
ScaleWidth = 5070
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "还原数据库"
Height = 372
Left = 720
TabIndex = 12
Top = 4680
Width = 1212
End
Begin VB.TextBox lbldatabase
BackColor = &H8000000A&
BorderStyle = 0 'None
Height = 375
Left = 480
TabIndex = 11
Top = 120
Width = 4095
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 2280
Top = 4080
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.TextBox lblcount
BackColor = &H8000000A&
Height = 375
Left = 2760
TabIndex = 10
Top = 3480
Width = 1815
End
Begin VB.TextBox lblupdate
BackColor = &H80000000&
Height = 375
Left = 2760
TabIndex = 8
Top = 2640
Width = 1815
End
Begin VB.TextBox lblcreate
BackColor = &H80000000&
Height = 405
Left = 2760
TabIndex = 6
Top = 1800
Width = 1815
End
Begin VB.TextBox lbltable
BackColor = &H80000000&
Height = 375
Left = 2760
TabIndex = 4
Top = 960
Width = 1815
End
Begin VB.CommandButton cmdclose
Caption = "关闭"
Height = 375
Left = 3000
TabIndex = 2
Top = 4080
Width = 1332
End
Begin VB.CommandButton cmdopen
Caption = "打开数据库"
Height = 375
Left = 720
TabIndex = 1
Top = 4080
Width = 1215
End
Begin MSComctlLib.TreeView TreeView1
Height = 3255
Left = 120
TabIndex = 0
Top = 600
Width = 2415
_ExtentX = 4260
_ExtentY = 5741
_Version = 393217
Style = 7
Appearance = 1
End
Begin VB.Label Label4
BackColor = &H8000000A&
Caption = "记录数目"
Height = 255
Left = 2760
TabIndex = 9
Top = 3120
Width = 1215
End
Begin VB.Label Label3
BackColor = &H00C0C0C0&
Caption = "数据更新日期"
Height = 255
Left = 2760
TabIndex = 7
Top = 2280
Width = 1215
End
Begin VB.Label Label2
BackColor = &H00C0C0C0&
Caption = "数据建立日期"
Height = 255
Left = 2760
TabIndex = 5
Top = 1440
Width = 1095
End
Begin VB.Label Label1
Caption = "表名"
Height = 255
Left = 2760
TabIndex = 3
Top = 600
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim db As Database
Dim tbl As TableDef
Private Sub cmdclose_Click()
Rem db.Close
End
End Sub
Private Sub cmdopen_Click()
Dim destination As String
Dim conn As New ADODB.Connection
TreeView1.Nodes.Clear
Dim fld As Field
Dim nodx As Node
CommonDialog1.Filter = "*.mdb|*.mdb"
CommonDialog1.DialogTitle = "open database"
CommonDialog1.FileName = vbNullString
CommonDialog1.ShowOpen
If Len(CommonDialog1.FileName) = 0 Then Exit Sub
lbldatabase = CommonDialog1.FileName
CommonDialog1.Filter = "*.mdb|*.mdb"
CommonDialog1.DialogTitle = "save database"
CommonDialog1.ShowSave
destination = CommonDialog1.FileName
Rem FileCopy lbldatabase, destination
FileCopy lbldatabase, destination
Set nodx = TreeView1.Nodes.Add(, , "p", "tables")
Set db = DBEngine.Workspaces(0).OpenDatabase(CommonDialog1.FileName)
Dim constr As String
constr = "Provider=Microsoft.Jet.OLEDB.3.51;" & "data source='" & CommonDialog1.FileName & "'"
conn.Open constr
For Each tbl In db.TableDefs
Set nodx = TreeView1.Nodes.Add("p", tvwChild, tbl.Name, tbl.Name)
For Each fld In tbl.Fields
Set nodx = TreeView1.Nodes.Add(tbl.Name, tvwChild, , fld.Name)
Next fld
Next
nodx.EnsureVisible
TreeView1.Style = 7
TreeView1.BorderStyle = ccFixedSingle
End Sub
Private Sub Command1_Click()
Dim lbldatabase As String
Dim destination As String
CommonDialog1.Filter = "*.mdb|*.mdb"
CommonDialog1.DialogTitle = "open database"
CommonDialog1.FileName = vbNullString
CommonDialog1.ShowOpen
If Len(CommonDialog1.FileName) = 0 Then Exit Sub
lbldatabase = CommonDialog1.FileName
CommonDialog1.Filter = "*.mdb|*.mdb"
CommonDialog1.DialogTitle = "save database"
CommonDialog1.ShowSave
destination = CommonDialog1.FileName
FileCopy lbldatabase, destination
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
If Node.Children > 0 And Node.Key <> "p" Then
lbltable.Text = Node.Text
Set tbl = db.TableDefs(Node.Text)
lblcreate.Text = tbl.DateCreated
lblupdate.Text = tbl.LastUpdated
lblcount.Text = tbl.RecordCount
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -