This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Recommended way to attach/detach database to sql server
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Aug 01, 2008
03:26 PM
Recommended way to attach/detach database to sql server
In the past we have used SQLDMO and call a C++ dll through installscript to attach and detach our databases. With Sql 2005 Express SQLDMO is no longer included and Microsoft says you should use SQLSMO.
I tried writing a C# dll using SQLSMO and in the installscript using DotNetCoCreateObject to call the functions I wrote. But I get an error (I am running Vista) saying that the assembly does not allow partially trusted callers. I added the allowpartiallytrusted callers attribute to my C# assembly, but it does not seem to help. I think it is because SQLSMO does not allow partially trusted callers (whatever those are).
So I am wondering what my options are and what is the preferred method?
I can try wrapping my C# dll in C++ and call it in installscript like I was before. But I wonder if I would still get the same exception.
Or I can use osql to attach and detach. In SQLDMO we also called a function to make sure the sql server is started. I don't think osql has that capability.
Are there any other options? Or hints on how to get SQLSMO to work?
Thank you.
I tried writing a C# dll using SQLSMO and in the installscript using DotNetCoCreateObject to call the functions I wrote. But I get an error (I am running Vista) saying that the assembly does not allow partially trusted callers. I added the allowpartiallytrusted callers attribute to my C# assembly, but it does not seem to help. I think it is because SQLSMO does not allow partially trusted callers (whatever those are).
So I am wondering what my options are and what is the preferred method?
I can try wrapping my C# dll in C++ and call it in installscript like I was before. But I wonder if I would still get the same exception.
Or I can use osql to attach and detach. In SQLDMO we also called a function to make sure the sql server is started. I don't think osql has that capability.
Are there any other options? Or hints on how to get SQLSMO to work?
Thank you.
(1) Reply
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Aug 01, 2008
04:22 PM
Instead of writing the new code, you may want to install the Microsoft SQL Server 2005 Backward Compatibility Components available at Feature Pack for Microsoft SQL Server 2005. The package includes the latest version of SQL Distributed Management Objects (SQL-DMO) that works with Microsoft SQL Server 2005.
