码迷,mamicode.com
首页 > Windows程序 > 详细

C#通用数据访问类:一

时间:2018-07-21 21:21:29      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:upd   name   turn   span   command   ret   mes   open()   comm   

 1         private static string connString = ConfigurationManager.ConnectionStrings["connString"].ToString(); 
2
3 /// <summary> 4 /// 执行增、删、改操作 5 /// </summary> 6 /// <param name="sql">SQL语句</param> 7 /// <returns></returns> 8 public int Update(string sql) 9 { 10 SqlConnection sqlConnection = new SqlConnection(connString); 11 SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection); 12 try 13 { 14 sqlConnection.Open(); 15 return sqlCommand.ExecuteNonQuery(); 16 } 17 catch (Exception ex) 18 { 19 string errorinfo = "调用public int Update(string sql)方法时发生错误" + ex.Message; 20 WriteLog(errorinfo); 21 throw new Exception(errorinfo); 22 } 23 finally 24 { 25 sqlConnection.Close(); 26 } 27 }

 

C#通用数据访问类:一

标签:upd   name   turn   span   command   ret   mes   open()   comm   

原文地址:https://www.cnblogs.com/zhuyz0602/p/9347826.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!