欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

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

程序员文章站 2022-06-09 11:00:04
...

数据表中删除记录 避免用 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: 博客园 模板提供:沪江博客