As part of automating an installation, there's a need to create multiple databases and automate a bunch of things (add users, assign roles and schema, etc);
This following command is executed through ado.net SqlCommand.ExecuteNonQuery which generates an error saying the databases that are just created don't exist.... is there a work around?
Create Database foo ... Go
Alter Database foo ... Go
Create Database foo2 ... Go
Alter Database foo2 ... Go
Use Foo
....
Exception: FOO doesn't exist
any help is much appreciated