I'm trying to create a new database on my server programmatically using Microsoft.SqlServer.Management.Smo
, but it always fails to create the database:
Server svr = new Server(new ServerConnection(@".\SQLEXPRESS"));
Database db = new Database(svr, "TESTDB");
db.Create();
I get this error at db.create();
:
An unhandled exception of type Microsoft.SqlServer.Management.Smo.FailedOperationException' occurred in Microsoft.SqlServer.Smo.dll
The server's name is correct, and I'm using Windows authentication to connect to the server.
Please help and if there is any better way please let me know