📄 msde_detachnorthwind.vbs
字号:
' This script detaches a Northwind database from the default MSDE instance
' (local)\VSDOTNET in Visual Studio .NET
' robert
Option Explicit
On Error Resume Next
Dim oSQLDMO
Dim sServerName
Dim sDBName
Dim sTitle
Dim nAnswer
' Initialize strings
sServerName = "(local)\VSDOTNET"
sDBName = "nwind"
sTitle = "MSDE_DetachNorthwind"
nAnswer = MsgBox("Do you want to try to detach the following database?" & VbCrLf & VbCrLf & _
"Server Name: " & sServerName & VbCrLf & _
"Database Name: " & sDBName & VbCrLf, _
vbYesNo + vbQuestion, sTitle)
If nAnswer = vbYes Then
' Create SQLDMO.SQLServer object
Set oSQLDMO = WScript.CreateObject("SQLDMO.SQLServer")
If Err <> 0 Then
Call PrintError("Unable to create SQLDMO.SQLServer object.")
End If
If Not(oSQLDMO Is Nothing) Then
' Connect
oSQLDMO.LoginSecure = True
oSQLDMO.Connect(sServerName)
If Err <> 0 Then
Call PrintError("Unable to connect to " & sServerName)
Else
' Detach
Call oSQLDMO.DetachDB(sDBName)
If Err <> 0 Then
Call PrintError("Unable to detach " & sDBName & " database.")
End If
End If
Set oSQLDMO = Nothing
End If
If Err = 0 Then
Call MsgBox(sDBName & " database should be detached from " & sServerName & ".", _
vbInformation , sTitle)
Else
Call PrintError("An error occurred.")
End If
End If
Sub PrintError(sError)
Call MsgBox(sError & " " & VbCrLf & VbCrLf & _
"Error Number: " & Err.Number & VbCrLf & _
"Error Description: " & Err.Description, vbCritical, sTitle)
WScript.Quit
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -