关于数据库的问题?

.NET 框架—SQL服务器—L\NetSDK
建立一个空数据库123
之后想删除。
问,我该如何操作?

请各位高手前辈,指点一二,在下先行谢过。

---------------------------------------------------------------

' 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

把它存成.vbs 分离后就可以删除了

Published At
Categories with Web编程
Tagged with
comments powered by Disqus