|
-
Nov 4th, 2002, 03:13 AM
#1
Thread Starter
Addicted Member
HOW TO: Delete a SQL 7.0 database?
Hello there,
Does anybody knows how to delete a SQL Server 7.0 or MSDE database using VB. Pls show me some codes..
actually i do have d codes but it only works on SQL 2000
heres d code. (pls try to debug what is wrong)
Dim objRoot As Object
Set objRoot = CreateObject("SQLDMO.SQLServer")
objRoot.LoginTimeout = 60
objRoot.Connect "(local)", user, password
Call objRoot.KillDatabase("MyDatabase")
tried it on MSDE and SQL 7.0
it generates an error #2702-database do not exist
Your help is very much appreciated.
-
Nov 4th, 2002, 07:42 AM
#2
Fanatic Member
You will want to connect to a different database than the one you are dropping.
VB Code:
Dim oConn As Connection
Dim ConStr As String
Dim sSql As String
sSql = "Drop Database myDB"
ConStr = "Provider=SQLOLEDB.1;" & _
"Server=myServ;" & _
"Initial Catalog=master;" & _
"UID=" & sUID & ";" & _
"PWD=" & sPWD & ";"
Set oConn = New Connection
With oConn
.CursorLocation = adUseClient
.CommandTimeout = 10
.Open ConStr
.Execute sSql
.Close
End With
Set oConn = Nothing
Chris
Master Of My Domain
Got A Question? Look Here First
-
Nov 4th, 2002, 08:00 AM
#3
-
Nov 4th, 2002, 08:42 PM
#4
Thread Starter
Addicted Member
I solve it myself
Thanks a lot guys.
I solve it my self. My codes works on SQL 2000 and to make it work to MSDE or SQL 7.0 you must use:
objRoot.databases.remove([index],[owner])
thats it. (this code will work both on SQL 7.0 and 2000)
You guys continue helping those who needs our expertise.
until then...
Elbimbo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|