locked
attach/detach database (sql server 2005) RRS feed

  • Question

  • Hello!
     i try to detach/attach a remote database using visual studio 2005 ( c# ) it is possible?
     i detach/attach a local database, using this sample:



     SQLDMO.SQLServer srv = new SQLDMO.SQLServerClass();
                try
                {
                    srv.LoginSecure = false;
                    srv.Connect("server", "login", "pass");         
                  
                            srv.ExecuteImmediate("ALTER DATABASE " + nomeBd + " SET OFFLINE WITH ROLLBACK IMMEDIATE ", SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default, null);                     
                            srv.DetachDB(nomeBd, false);
                         
                       
                }


    any idea to solve my problem?
    thanks.
    Friday, June 20, 2008 2:20 PM

Answers