7
Answers

need to create db2015-2016, db2016-2017 in sql using c#

Photo of sweet guddu

sweet guddu

8y
604
1
<blockquote> need to create db2015-2016, db2016-2017 in sql using c#<br /> </blockquote>

Answers (7)

1
Photo of Nitin Sontakke
136 13.6k 15.3k 8y
Are you still stuck somewhere? Is given direction not sufficient? If so, please give precise area where you are not clear so that more details can be given.
Please provide maximum information and don't assume anything anything.
1
Photo of Rajeev Punhani
347 4.7k 1.6m 8y

Hi Guddu,

Please follow below link.

https://support.microsoft.com/en-us/kb/307283
0
Photo of Vinay Singh
295 6.3k 962.9k 8y
Hi
Please check the link
http://www.codeproject.com/Articles/10213/Create-an-SQL-Server-Database-Using-Csharp
https://support.microsoft.com/en-in/kb/307283
0
Photo of sweet guddu
NA 18 1.5k 8y
Rajiv Sir This is my Problem
i develop small software for my shop trading shop
i created dbconnection() class some code need as below
if i have 3 db file db1415, db1516, db1617
then application run in db1617 from d:\data\db1617.mdf on location
all table copy from old to new one
0
Photo of sweet guddu
NA 18 1.5k 8y
nitin sir. thanx for reply.
rajiv thx for reply
0
Photo of sweet guddu
NA 18 1.5k 8y
rajiv, I already read microsoft link . but i need incremented from textbox.
0
Photo of Nitin Sontakke
136 13.6k 15.3k 8y
I strongly suggest that do not include any special character (such has -, i.e. hyphen) in the name, it will be a headache later. Instead keep db name (also, table names, column names, etc.) simple. To give the effect of space, use _ underscore instead.
So your db name becomes db20152016, etc. Then again what is "db"? It doesn't tell anything about "function" or "business". So if this is Financial Year, call it FY20152016, etc.
Now to answer your question, all you have to do is construct a string of a SQL and fire it against a connection, by default keeping the master as your database.
For example, something as follows:
DateTime YearStart, YearEnd; // Assign appropriate values to these variables.
String query = "create database FY" + YearStart.Year.ToString() + YearEnd.Year.ToString() + ";" // add more script here if required.
I also suggest that you keep all your master tables in separate db and keep an entry of each such created db in master tables db, so that it can be used to show the drop down of years.