In order to create a database in c# you can use sql management objects
Youll need the following DLLs referenced in your project for the below snippet.
Microsoft.SqlServer.Management.Smo
This is dll can be found here: C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies
Here is a very basic create databse using SMO.
Server srv = new Server();
Database db = new Database(srv, "DavidsDB");
db.Create();
Or for ADO.NET you should be able to do the following
string ConnectionString = String.Format(@"Data Source = {0};User Id={1}; password={2}; Initial Catalog = {3};",
ConfigurationManager.AppSettings["DB_Server"],
ConfigurationManager.AppSettings["DB_User"],
ConfigurationManager.AppSettings["DB_Pass"],
ConfigurationManager.AppSettings["DB_Name"]);
string query = "CREATE DATABASE YourDatabaseHere";
SqlConnection connection = new SqlConnection(ConnectionString);
connection.Open();
SqlCommand queryCMD = new SqlCommand(query, connection);
queryCMD.Connection.Open();
queryCMD.ExecuteNonQuery();
Let me know if you have any other questions.
Also i see in your question that you want to be able to take a backup copy of your database everytime you update it. You have a lot of options here, i guess the question is how are you wanting to do this. You could use powershell scripts, sql management objects or some pre-determined sql scripts that you just run every time you update.