I am trying to create a new database programmatically using SMO (c#).
I am working on SQL Server 2005. This is the code :
ServerConnection connection = new ServerConnection(serverName, userName, password);
Server sqlServer = new Server(connection);
Database newDB = new Database(sqlServer, databaseName);
newDB.Create();
I get the exception :
“Create failed for database.”
What could be the problem and how can I create a new DB?
thanks…
I tried this: with a sysadmin user, everything works just fine. With a “normal” user, I get the same error as you do.
Try this:
Do you see a
msg2and amsg3?? What do they say???When using a user without the necessary permission, my
msg3is very clear: