怎么用命令建数据库
怎么用命令建数据库 要有 数据存放路径 日志存放路径 起始文件大小 增长量 最大文件大小 谢谢
//创建SQL Server数据库 string MySQL = "use master;" + "IF DB_ID(N'MyDatabase') IS NOT NULL " + "DROP DATABASE MyDatabase;" + "CREATE DATABASE MyDatabase " + "ON(NAME=MyDatabase_dat,FILENAME=\"C:\\MyDatabase.mdf\",SIZE=[color=#800000; font-weight: bold]5[/color],MAXSIZE=[color=#800000; font-weight: bold]10[/color],FILEGROWTH=[color=#800000; font-weight: bold]1[/color]) " + "LOG ON(NAME=MyDatabase_log,FILENAME=\"C:\\MyDatabase.ldf\",SIZE=[color=#800000; font-weight: bold]2[/color],MAXSIZE=[color=#800000; font-weight: bold]5[/color],FILEGROWTH=[color=#800000; font-weight: bold]1[/color])"; SqlConnection MyConnection = new SqlConnection("Data Source=.;Initial Catalog=;Integrated Security=True"); SqlCommand MyCommand = new SqlCommand(MySQL, MyConnection); try { MyCommand.Connection.Open(); MyCommand.ExecuteNonQuery(); MessageBox.Show("成功创建数据库", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { MyConnection.Close(); }