当前位置:Gxlcms > mysql > 数据表中删除记录避免用Delete应单独设置字段,防止误删

数据表中删除记录避免用Delete应单独设置字段,防止误删

时间:2021-07-01 10:21:17 帮助过:40人阅读

数据表中删除记录 避免用 Delete 应单独设置字段,防止误删 private void DeleteProductInfo( int TempID){ SqlConnection con = null ; bool flag = false ; try {con = new SqlConnection(ConfigurationManager.AppSettings[ "ConnectionString" ]); string

数据表中删除记录 避免用 Delete 应单独设置字段,防止误删

private void DeleteProductInfo(int TempID){ SqlConnection con = null; bool flag = false; try { con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]); string sql = "update T_Temp set Deleted=1 where TempID=" + TempID; con.Open(); SqlCommand com = new SqlCommand(sql, con); flag = com.ExecuteNonQuery() > 0 ? true : false; con.Close(); } catch (SqlException se) { } finally { con.Close(); } if (flag) { myShare.WebMessageBox(this.Page, "删除成功!"); } else { myShare.WebMessageBox(this.Page, "删除信息时出错,请重试!"); }}

posted on

Copyright ©2013 porray Powered By: 博客园 模板提供:沪江博客

人气教程排行