📄 renamedb.frm
字号:
VERSION 5.00
Begin VB.Form RenameDB
BorderStyle = 3 'Fixed Dialog
Caption = "修改试题数据库名称"
ClientHeight = 2280
ClientLeft = 45
ClientTop = 330
ClientWidth = 5025
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2280
ScaleWidth = 5025
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdExit
Cancel = -1 'True
Caption = "关闭"
Height = 315
Left = 2692
TabIndex = 5
Top = 1335
Width = 1005
End
Begin VB.CommandButton cmdOk
Caption = "确定"
Default = -1 'True
Height = 315
Left = 1507
TabIndex = 4
Top = 1335
Width = 1005
End
Begin VB.TextBox txtNewName
Height = 330
Left = 1890
TabIndex = 3
Top = 855
Width = 2670
End
Begin VB.TextBox txtOldName
Height = 330
Left = 1890
Locked = -1 'True
TabIndex = 1
Top = 330
Width = 2670
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "修改数据库名称不改变数据库文件名,原数据库名即文件名!"
Height = 180
Left = 60
TabIndex = 6
Top = 2085
Width = 4860
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "请输入新名称:"
Height = 180
Left = 645
TabIndex = 2
Top = 930
Width = 1260
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "当前数据库名称:"
Height = 180
Left = 465
TabIndex = 0
Top = 420
Width = 1440
End
End
Attribute VB_Name = "RenameDB"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdExit_Click()
Unload Me '关闭窗体
End Sub
Private Sub cmdOk_Click()
On Error GoTo DealError
If Trim(txtNewName) = "" Then
MsgBox "请输入数据库的新名称!", vbCritical
txtNewName.SetFocus
Else
Dim objCn As New Connection
With objCn
.Provider = "SQLOLEDB"
.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False"
.Open '打开连接
.Execute "Alter Database " & ThisDBName _
& " modify name= " & Trim(txtNewName)
.Close
End With
ThisDBName = Trim(txtNewName)
MsgBox "数据库名称已被成功修改!"
txtOldName = ThisDBName
Set objCn = Nothing
End If
Exit Sub
DealError:
'ShowError "程序执行出错,错误信息如下:" & vbCrLf & Err.Description
End Sub
Private Sub Form_Load()
txtOldName = ThisDBName '显示当前试题数据库名称
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -