How to create local database Instance using SMO
Asked Answered
T

1

3

I have installed localdatabase and created a shared instance, and using smo I am able to create localdatabase.

For my requirement I have to create a localdb shared instance.

I am creating local database using SMO like this.

ServerConnection serConn = new ServerConnection(@"(localdb)\.\sharedIns");
Server ldbServer = new Server(serConn);

Database db = new Database(ldbServer , "databaseName");
db.Create();

Before creating database, I am creating shared instance through command prompt using sqllocaldb.exe like this

c:\>sqllocaldb create testIns
c:\>sqllocaldb share testIn sharedIns

I want to remove these manual steps and create localdb shared instance using SMO. How to do this?

Thetic answered 1/7, 2013 at 14:55 Comment(1)
Does this answer your question? Is there a way to create a sqllocaldb instance in c#?Mishamishaan
M
2

I maintain an open-source .NET library that wraps the underlying LocalDB native API, exposing an interface that allows you do this this kind of thing. See the below links for more detail:

Mcgurn answered 10/2, 2014 at 11:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.