So I'm developing a web application where each user has it's own database. What i want is to automate the process of create the user specific database when he registers.
My idea is to create a new empty database with a custom name and then run a pre-made sql script to generate the tables and default values for this database.
Edit I think I haven't been clear before.
I create the database as follows:
using (var conn = new SqlConnection("data source=MySource; uid=MyUser; pwd=MyPassword;"))
{
using (var cmd = new SqlCommand())
{
conn.Open();
cmd.Connection = conn;
cmd.CommandText = "Create Database MYNewDB;";
cmd.ExecuteNonQuery();
}
}
Is there a way to (after this) execute the scripts saved in .sql file to create the tables and values for this new data base?