日期:2014-05-17 浏览次数:20434 次
public partial class ProManagement_NewProgram : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString.Get("Project_ID") != null) { DetailsView1.DefaultMode = DetailsViewMode.Edit; } } protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e) { string str1; str1 = (DetailsView1.FindControl("TextBox1") as System.Web.UI.WebControls.TextBox).Text.ToString(); String str; SqlConnection myConn = new SqlConnection("Server=LIUKAI-THINK;Integrated security=SSPI;database=master"); str = "CREATE DATABASE "+str1+" ON PRIMARY " + "(NAME = str1_Data, " + "FILENAME = 'D:\\"+str1+".mdf', " + "SIZE = 3MB, MAXSIZE = 10MB, FILEGROWTH = 10%) " + "LOG ON (NAME = MyDatabase_Log, " + "FILENAME = 'D:\\"+str1+".ldf', " + "SIZE = 1MB, " + "MAXSIZE = 5MB, " + "FILEGROWTH = 10%)"; SqlCommand myCommand = new SqlCommand(str, myConn); myConn.Open(); myCommand.ExecuteNonQuery(); if (myConn.State == ConnectionState.Open) { myConn.Close(); } EndEditing(); }
SqlConnection myConn = new SqlConnection("Server=LIUKAI-THINK;Integrated security=SSPI;database=master"); string str2; str2 = "CREATE TABLE Project" + "Project_ID int," + "(Name nvarchar(256) NULL," + "Owner nvarchar(256) NULL," + "Description char(10) NULL" + "PathToDatabaseFiles nvarchar(256) NULL" + "AutoShrink int NULL" + "Epoch datetime NULL" + "State int NULL)"; SqlCommand myCommand1 = new SqlCommand(str2, myConn); myConn.Open(); myCommand.ExecuteNonQuery(); myConn.Close();