⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 这是一个用vb和SQL开发的创建加密的数据库
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   Caption         =   "创建加密的数据库"
   ClientHeight    =   2550
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3420
   LinkTopic       =   "Form1"
   ScaleHeight     =   2550
   ScaleWidth      =   3420
   StartUpPosition =   1  '所有者中心
   Begin MSComDlg.CommonDialog Cmdlg1 
      Left            =   1530
      Top             =   1875
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
      Filter          =   "MS Access Databases (*.mdb)"
   End
   Begin VB.CommandButton cmdEnd 
      Cancel          =   -1  'True
      Caption         =   "退出程序"
      Default         =   -1  'True
      Height          =   435
      Left            =   180
      TabIndex        =   3
      Top             =   1920
      Width           =   3075
   End
   Begin VB.CommandButton cmdDecryptDatabase 
      Caption         =   "解密数据库"
      Height          =   435
      Left            =   180
      TabIndex        =   2
      Top             =   1260
      Width           =   3075
   End
   Begin VB.CommandButton cmdEncryptDatabase 
      Caption         =   "加密已存在的数据库"
      Height          =   435
      Left            =   180
      TabIndex        =   1
      Top             =   720
      Width           =   3075
   End
   Begin VB.CommandButton cmdCreateDatabase 
      Caption         =   "创建一个加密的数据库"
      Height          =   435
      Left            =   165
      TabIndex        =   0
      Top             =   180
      Width           =   3075
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'定义数据库
Dim db As Database
'定义字符串变量
Dim NDatabase, NDatabasename, S As String
Private Sub dbED(cAction As Integer)
  '判断是加密还是解密
  If (cAction = dbEncrypt) Then
      S = "加密"
    Else
      S = "解密"
  End If
  With Cmdlg1
      .FileName = ""
      .DialogTitle = "数据库" & S
      .Action = 1
      NDatabasename = .FileName
      If (NDatabasename = "") Then Exit Sub
      .FileName = ""
      .DialogTitle = "数据库" & S
      .Action = 2
      NDatabase = .FileName
      If (NDatabase = "") Then Exit Sub
  End With
  '创建一个新的加密的数据库
  DBEngine.CompactDatabase NDatabasename, NDatabase, , cAction
End Sub
Private Sub Form_Load()
  With DBEngine
      '连接系统数据库
      .SystemDB = App.Path & "\system.mdw"
      '设置默认的用户和密码
      .DefaultUser = "admin"
      .DefaultPassword = "111"
  End With
  With Cmdlg1
      .Flags = cdlOFNExplorer
      .DefaultExt = "mdb"
  End With
End Sub
Private Sub cmdCreateDatabase_Click()     '创建一个新的加密的数据库
  With Cmdlg1
      .FileName = ""
      .DialogTitle = "创建加密的数据库"
      .Action = 2
      NDatabase = .FileName
      If (NDatabase = "") Then Exit Sub
  End With
  Set db = DBEngine(0).CreateDatabase(NDatabase, dbLangGeneral, dbEncrypt)
  Set db = Nothing
End Sub
Private Sub cmdEncryptDatabase_Click()     '加密一个已存在的数据库
  dbED dbEncrypt
End Sub
Private Sub cmdDecryptDatabase_Click()     '解密数据库
  dbED dbDecrypt
End Sub
Private Sub cmdEnd_Click()
  Unload Me
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -