0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
string commQuery = "CREATE DATABASE " + this.textBox1.Text +
" ON" +
" ( " +
"NAME =" + this.textBox1.Text + ", " +
"FILENAME =" + this.textBox2.Text +
"SIZE = 100mb, " +
"MAXSIZE = unlimited, " +
"FILEGROWTH = 5mb" +
" ) " +
"LOG ON " +
" ( " +
"NAME =" + this.textBox1.Text + ", " +
"FILENAME =" + this.textBox2.Text +
"SIZE = 3mb, " +
"MAXSIZE = 50mb, " +
"FILEGROWTH = 5mb" +
" ) ";
SqlConnection conSQL = new SqlConnection("Data Source = (local);" + "Integrated security = True;" + "database = master");
SqlCommand commSQL = new SqlCommand("", conSQL);
commSQL.CommandType = CommandType.Text;
commSQL.CommandText = commQuery.ToString();
conSQL.Open();
commSQL.ExecuteNonQuery();
conSQL.Close();
очень нравиться совершенство стиля формирования БД на сервере и защита от SQL иньекций :-D
Запостил:
ageron ,
13.11.2010 (Updated 24.03.2018 )
Комментарии (1) RSS