首页 > 代码库 > 用ADO.NET存入数据库

用ADO.NET存入数据库

点击按钮存入登录名和密码:

 1 const string connstr = @"data source=USER-20160705UW\JSQL;initial catalog=Test;integrated security=True"; //ADO
 2 
 3 protected void btn_Click(object sender, EventArgs e)
 4 {
 5 TestEntities ae = new TestEntities();
 6 string un = Request["id"];
 7 string pwd = Request["pwd"];
 8 SqlConnection conn = new SqlConnection(connstr);
 9 conn.Open();
10 string mysql = "insert into [Table_1] values(‘" + un + "‘,‘" + pwd + "‘)";
11 SqlCommand cmd = new SqlCommand(mysql, conn);
12 cmd.ExecuteNonQuery();
13 conn.Close();
14 }

 

用ADO.NET存入数据库