I\'m creating a database using SQL Server Management Objects.
I wrote the following method to generate a database:
public static void CreateClientDat
You have to approach the database creation a little bit different. The code below handles the database creation correctly. Try it ;)
private void CreateDatabase(string databaseName)
{
Microsoft.SqlServer.Management.Smo.Server sqlServer =
new Microsoft.SqlServer.Management.Smo.Server(_connection);
Database createdDatabase = new Database();
createdDatabase.Name = databaseName;
createdDatabase.Parent = sqlServer;
createdDatabase.Create();
}
In the code below, the _connection is a
Microsoft.SqlServer.Management.Smo.ServerConnectionobject by the way.
[Edit] Modified the code so the exception is not swallowed anymore.