解决方法
KB307283解释了如何使用ADO.NET创建数据库.
来自文章:
String str; sqlConnection myConn = new sqlConnection ("Server=localhost;Integrated security=SSPI;database=master"); str = "CREATE DATABASE MyDatabase ON PRIMARY " + "(NAME = MyDatabase_Data," + "FILENAME = 'C:\\MyDatabaseData.mdf'," + "SIZE = 2MB,MAXSIZE = 10MB,FILEGROWTH = 10%) " + "LOG ON (NAME = MyDatabase_Log," + "FILENAME = 'C:\\MyDatabaseLog.ldf'," + "SIZE = 1MB," + "MAXSIZE = 5MB," + "FILEGROWTH = 10%)"; sqlCommand myCommand = new sqlCommand(str,myConn); try { myConn.Open(); myCommand.ExecuteNonQuery(); MessageBox.Show("DataBase is Created Successfully","MyProgram",MessageBoxButtons.OK,MessageBoxIcon.Information); } catch (System.Exception ex) { MessageBox.Show(ex.ToString(),MessageBoxIcon.Information); } finally { if (myConn.State == ConnectionState.Open) { myConn.Close(); } }