# re: .NET与SQL SERVER数据库连接代码 回复 更多评论
2012-04-28 10:57 by
protected void Button1_Click(object sender, EventArgs e)
{
string sql = "Data Source=PC-201202251849;Initial Catalog=us;Integrated Security=True";
SqlConnection con = new SqlConnection(sql);
string strsql = "insert into user(id,name)values('" + TextBox1.Text +"','" + TextBox2.Text +",')";// + "'," + TextBox1.Text + ",'" + TextBox1.Text,mima,shiming
SqlCommand cmd = new SqlCommand(strsql, con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();