C#中执行SQL语句

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
C#中执行SQL语句
//SQL查询语句
  public DataTable query(string sql)
  {
   //server=127.0.0.1;
   DataTable dt=new DataTable();
   //DataRow dr;
   string connString = "server=127.0.0.1;uid=sa;pwd=;database=TJPTTC";
   SqlConnection conn = new SqlConnection(connString);
   SqlDataAdapter adapter = new SqlDataAdapter(sql,conn);
   adapter.Fill(dt);
   return dt;
  }
//SQL非查询语句
  public void noQuery(string sql)
  {
   //server=127.0.0.1;
   string connString = "server=GLASSESONION;uid=sa;pwd=;database=TJPTTC";
   SqlConnection conn = new SqlConnection(connString);
   SqlCommand cmd = new SqlCommand(sql,conn);
   conn.Open();
   cmd.ExecuteNonQuery();
   conn.Close(); 
  }

C#中执行SQL语句,布布扣,bubuko.com

C#中执行SQL语句

上一篇:Photoshop制作动感喷溅人物海报


下一篇:Spring中国教育管理中心-Apache Cassandra 的 Spring 数据教程十四