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

📄 frmbackrest.frm

📁 数据库备份与恢复的程序
💻 FRM
📖 第 1 页 / 共 2 页
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmBackRest 
   Caption         =   "数据备份/恢复窗体"
   ClientHeight    =   5865
   ClientLeft      =   1890
   ClientTop       =   2370
   ClientWidth     =   7845
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   ScaleHeight     =   5865
   ScaleWidth      =   7845
   Begin VB.Frame Frame1 
      Caption         =   "操作"
      Height          =   3615
      Left            =   3900
      TabIndex        =   11
      Top             =   0
      Width           =   3885
      Begin VB.CommandButton Command1 
         Caption         =   "退  出"
         Height          =   435
         Left            =   2760
         TabIndex        =   21
         Top             =   2850
         Width           =   1035
      End
      Begin VB.CommandButton cmdBackup 
         Caption         =   "备   份"
         Height          =   435
         Left            =   300
         TabIndex        =   16
         Top             =   2850
         Width           =   1035
      End
      Begin VB.CommandButton cmdRestore 
         Caption         =   "恢  复"
         Height          =   435
         Left            =   1560
         TabIndex        =   15
         Top             =   2850
         Width           =   1035
      End
      Begin VB.TextBox txtDataFileName 
         Height          =   288
         Left            =   210
         TabIndex        =   14
         Top             =   2190
         Width           =   3375
      End
      Begin VB.ComboBox cmbDatabaseName 
         Height          =   300
         Left            =   210
         TabIndex        =   13
         Top             =   630
         Width           =   3375
      End
      Begin VB.CommandButton cmdBrowse 
         Caption         =   "浏览..."
         Height          =   375
         Left            =   2610
         TabIndex        =   12
         Top             =   1650
         Width           =   975
      End
      Begin MSComDlg.CommonDialog CommonDialog1 
         Left            =   1770
         Top             =   3660
         _ExtentX        =   847
         _ExtentY        =   847
         _Version        =   393216
         DialogTitle     =   "数据文件名:"
         InitDir         =   "c:\temp\"
      End
      Begin VB.Label Label2 
         Caption         =   "选择要备份/恢复的数据库名称:"
         Height          =   255
         Left            =   210
         TabIndex        =   18
         Top             =   270
         Width           =   2775
      End
      Begin VB.Label Label3 
         Caption         =   "备份/恢复的文件名:"
         Height          =   315
         Left            =   210
         TabIndex        =   17
         Top             =   1800
         Width           =   2175
      End
   End
   Begin VB.Frame frmConnectionInfo 
      Caption         =   "连接数据库"
      Height          =   855
      Left            =   30
      TabIndex        =   8
      Top             =   0
      Width           =   3855
      Begin VB.ComboBox txtServerName 
         Height          =   300
         Left            =   1290
         TabIndex        =   22
         Top             =   330
         Width           =   2385
      End
      Begin VB.Label lblServer 
         Caption         =   "服务器名称:"
         Height          =   255
         Left            =   240
         TabIndex        =   9
         Top             =   360
         Width           =   1005
      End
   End
   Begin VB.Frame frmAuthorization 
      Caption         =   "登录方式"
      Height          =   2715
      Left            =   30
      TabIndex        =   1
      Top             =   900
      Width           =   3855
      Begin VB.CommandButton Command2 
         Caption         =   "帮 助"
         Height          =   435
         Left            =   2880
         TabIndex        =   23
         Top             =   2010
         Width           =   825
      End
      Begin VB.CommandButton cmdConnect 
         Caption         =   "连接服务器"
         Height          =   435
         Left            =   210
         TabIndex        =   20
         Top             =   2010
         Width           =   1155
      End
      Begin VB.CommandButton cmdDisconnect 
         Caption         =   "断开连接"
         Height          =   435
         Left            =   1590
         TabIndex        =   19
         Top             =   2010
         Width           =   1155
      End
      Begin VB.TextBox txtUserName 
         Height          =   288
         Left            =   1320
         TabIndex        =   5
         Top             =   1080
         Width           =   2292
      End
      Begin VB.TextBox txtPassword 
         Height          =   288
         IMEMode         =   3  'DISABLE
         Left            =   1320
         PasswordChar    =   "*"
         TabIndex        =   4
         Top             =   1440
         Width           =   2292
      End
      Begin VB.OptionButton optWinNTAuth 
         Caption         =   "使用Windows身份验证"
         Height          =   495
         Left            =   210
         TabIndex        =   3
         Top             =   180
         Width           =   2892
      End
      Begin VB.OptionButton optSSAuth 
         Caption         =   "使用 SQL Server 身份验证"
         Height          =   252
         Left            =   240
         TabIndex        =   2
         Top             =   720
         Width           =   3252
      End
      Begin VB.Label lblUserName 
         Caption         =   "用户名:"
         Height          =   255
         Left            =   510
         TabIndex        =   7
         Top             =   1140
         Width           =   975
      End
      Begin VB.Label lblPassword 
         Caption         =   "密  码:"
         Height          =   225
         Left            =   510
         TabIndex        =   6
         Top             =   1500
         Width           =   555
      End
   End
   Begin VB.TextBox txtStatus 
      ForeColor       =   &H00FF0000&
      Height          =   1965
      Left            =   60
      Locked          =   -1  'True
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   0
      Top             =   3840
      Width           =   7725
   End
   Begin VB.Label lblQueryResults 
      Caption         =   "状态栏:"
      Height          =   165
      Left            =   60
      TabIndex        =   10
      Top             =   3660
      Width           =   615
   End
End
Attribute VB_Name = "frmBackRest"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'备份/恢复数据库
'张元卿
'2001.10.11
'状态:完成
'为了能使该模块备份恢复任何数据库,故把它单独列出来,因为把它放在工程时,工程本身所运行的数据库不能被恢复
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit

Dim gSQLServer As SQLDMO.SQLServer
Dim WithEvents oBackupEvent As SQLDMO.Backup
Attribute oBackupEvent.VB_VarHelpID = -1
Dim WithEvents oRestoreEvent As SQLDMO.Restore
Attribute oRestoreEvent.VB_VarHelpID = -1
Public goSQLServerDMOApp As SQLDMO.Application

Dim gbConnected As Boolean
Dim gDatabaseName As String
Dim gBkupRstrFileName As String
Dim gBkupRstrFilePath As String

Const gTitle = "连接服务器"


Private Sub Command1_Click()
Unload Me
End Sub

Private Sub Command2_Click()
Dim Path As String
'
'    Path = App.Path & "\data"
'    If right(Path, 1) <> "\" Then Path = Path & "\"
'    ReadFileToTextBox Path & "Help.txt", txtStatus
    txtStatus.ForeColor = vbBlue
    txtStatus.Text = "帮助:" & vbCrLf & "    该窗体可以帮助您实现MSSQL Server 数据库的备份和恢复,左边主要是对服务器的登录服务,其中服务器名称可以选择,您也可以自己输入服务器名称。" & vbCrLf & "    登录方式选项中,您可以选择Windows的登录方式,也可以选择Sql Server 的登录方式,这要根据您SQL Server安装登录时的选项所定。 " + vbCrLf & "    在进行数据备份或恢复之前必须连接服务器,否则一切都无法进行。" + vbCrLf & "    在右边选择您所要备份或恢复的数据库名称,浏览按钮能让您选择您所要保存或者是读取数据的路径。" + vbCrLf & "    注意:在进行数据库恢复的时候。您必须保证没有其它的计算机连接到该数据库,否则您的操作是不会成功的。" + vbCrLf & "    沈阳汉华软件有限公司。    TEL: 024-84820482"

End Sub

Private Sub Form_Load()
On Error GoTo ErrHandler:
  Dim I As Integer
'   mytools.CenterForm Me '让窗体居中显示
'   mytools.AlwaysOnTop Me '让窗口一直显示在最上面
    Set gSQLServer = Nothing
    optWinNTAuth.Value = True
    gbConnected = False
    WinNTAuthOptionsOn
    buttonsConnectClosed
    
Set goSQLServerDMOApp = New SQLDMO.Application
  
  Dim namX As NameList
  Set namX = goSQLServerDMOApp.ListAvailableSQLServers
  For I = 1 To namX.Count
    txtServerName.AddItem namX.Item(I)
     txtServerName.ListIndex = 0
  Next
  'Show top server
      
  
  '当我们在TextBox上面按下鼠标右键时,TextBox
'总是会显示含有 "撤消,剪切,复制,粘贴......"
'的快捷菜单,如果叫TextBox不要这么做呢?

'  prevWndProc = GetWindowLong(txtStatus.hWnd, GWL_WNDPROC)
'    SetWindowLong txtStatus.hWnd, GWL_WNDPROC, AddressOf WndProc
'FrmMove Me, MdiMenu

ErrHandler:
'    MsgBox "服务器搜索不成功,请退出重试!", vbOKOnly, "系统提示"
'    Exit Sub
End Sub

Private Sub Form_Unload(Cancel As Integer)
    If gbConnected = True Then
        Call gSQLServer.DisConnect
    End If
    If Not gSQLServer Is Nothing Then
        Set gSQLServer = Nothing
    End If
    '恢复控件句柄
'    If prevWndProc <> 0 Then
'        SetWindowLong txtStatus.hWnd, GWL_WNDPROC, prevWndProc
'        prevWndProc = 0
'    End If
End Sub



Private Sub cmdConnect_Click()
    Dim ServerName As String
    Dim UserName As String
    Dim Password As String

    On Error GoTo ErrHandler:

    If gSQLServer Is Nothing Then

⌨️ 快捷键说明

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