📄 分离数据库.frm
字号:
VERSION 5.00
Begin VB.Form 分离数据库
Caption = "分离数据库"
ClientHeight = 3990
ClientLeft = 60
ClientTop = 345
ClientWidth = 5565
LinkTopic = "Form1"
ScaleHeight = 3990
ScaleWidth = 5565
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "分离数据库"
Height = 855
Left = 960
TabIndex = 0
Top = 1560
Width = 2775
End
End
Attribute VB_Name = "分离数据库"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
If MsgBox("确定要分离数据库吗?分离后将不能继续系统运行!请慎重!", 4 + 32, "系统提示") = 6 Then
Dim zhu As New ADODB.Recordset
Dim con As Object
Dim STR As String
Set con = New ADODB.Connection
con.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa"
con.Open
zhu.Open "select * from master.dbo.sysdatabases where name ='xscj'", con, 3, 1
If Not zhu.EOF Then
STR = "EXEC sp_detach_db @dbname = 'xscj'"
'分离 pubs 数据库
con.Execute STR
MsgBox "数据库分离成功!"
Else
MsgBox "当前数据库未连接"
Me.Hide
End If
Else
Unload Me
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -