none
attach/detach database sql server 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 3:59 PM

Answers

  • Probably easiest just to use the system stored procedures:

    http://www.databasejournal.com/features/mssql/article.php/2224361
    Friday, June 20, 2008 5:17 PM

All replies