ADO.NET操作
连接:
1 using System.Data.SqlClient;
2
3 SqlConnection conn = new SqlConnection("xxx");
4
5 string sql = "xxx";
6
7 SqlCommand comm = new SqlCommand(sql, conn);
8
9 conn.Open();
10
11 comm.ExecuteNonQuery();
12
13 conn.Close();
查(绑定到DataGridView)
Code
1 using System.Data.SqlClient;
2
3 SqlConnection conn = new SqlConnection("xxx");
4
5 string sql = "xxx";
6
7 SqlDataAdapter da = new SqlDataAdapter(sql, conn);
8
9 DataSet ds = new DataSet();
10
11 da.Fill(ds);
12
13 dataGridView1.DataSource = ds.Tables[0];
14
15 //要更新 查询语句要 查询主键列
16
17 SqlCommandBuilder sd = new SqlCommandBuilder(da);
18
19 da.Update(ds.Tables[0]);
补充:Web开发 , ASP.Net ,