Saturday, February 25, 2012

Database remove/delete

How can I remove/delete a database.

I try (below) but not work:

Dim wServer As New Server(strSqlName)

wServer.Databases("DataBaseName").Drop()

Thanks,

Try defining a Database object first, as in this sample:

Dim srv1 As Server
srv1 = New Server("MyServer")
'Define a Database object variable
Dim db1 As Database
'Reference the database
db1 = srv1.Databases("Test_Database")
Console.WriteLine(db1.CreateDate)
'Remove the database.
db1.Drop()

I've tested this and it works.

|||

Thanks Allen.

Very good.

I am tested too and it works very well.

Marsenne

No comments:

Post a Comment