日期:2014-05-18 浏览次数:20738 次
var ok = new SqlConnection(); ok.ConnectionString = @"Data Source=.\SQLEXPRESS;Integrated Security=True;User Instance=True";//连接字符串 ok.Open(); var cn = new SqlCommand(); cn.Connection = ok; //假设你的textbox的id是companyName cn.CommandText = "INSERT INTO userRgs (companyName) VALUES("+companyName.Text.Trim()+")"; cn.ExecuteNonQuery(); ok.Close();