Friday, March 9, 2012

Detach sql2000 msde database using SMO.

Hello,

I am trying to detach a database from an instance of msde 2000 using smo. When I call the Server.DetachDatabase function using my valid server object I get the following error.

"This method or property is accessible only while working against SQL Server 2005 or later."

Does anyone know if it is possible to detach a msde database using the .net smo objects.

What I am trying to do is detach the database and then re-atach to an instance of sqlexpress. I thought about just stopping the server and copying the mdf file to a new location but I cannot figure out how to stop the server and restart it using smo.

Thanks,

Oh you don't have to go through all of that trouble just use the transfer class. Be sure to look at the information in MSDN regarding the Transfer class (specifically regarding its limitations). But going from 2000 to a 2005 DB should be well within its capabilities. Use the overloaded constructor that takes an existing database object to get started.

Hope this helps.

Michael

|||I suspect this may be a bug that you are running into. Detaching a SQL Server 2000 Database is supported by SMO. Could you post a small repro source code here so I can take a look?|||

Here is the main part of the code. I get an exception on the detach function that tells me that this function is valid on sql2005 databases only. The server object is valid and connected and the function will work on a 2005 database.

Dim KBMSS As Server = Nothing

Dim svc As New ServerConnection

With svc

.ApplicationName = Application.ProductName

.ServerInstance = ServerName

.StatementTimeout = 30

.LoginSecure = False

.Login = "sa"

.Password = "kbmsa"

End With

KBMSS = New Server(svc)

KBMSS.DetachDatabase("KBM", False)

|||

I've had a similar message when attempting to itterate through triggers in a database

connects =

m_srvconnSelectedServerConnection.ServerInstance = comboServer.Text;
m_srvconnSelectedServerConnection.LoginSecure = false;
m_srvconnSelectedServerConnection.Login = this.textUser.Text;
m_srvconnSelectedServerConnection.Password = this.textPassword.Text;
m_serverSelectedServer = new Server(m_srvconnSelectedServerConnection);

itterate triggers =

Database SelectedDatabase = m_serverSelectedServer.Databases[comboDB.Text];

foreach (Trigger trgTRG in SelectedDatabase.Triggers)
{
}

version of connected server reports =

?m_serverSelectedServer.Information.Version
{8.0.760}

cheers

No comments:

Post a Comment