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

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

WBOY
WBOYOriginal
2016-06-07 17:39:101407browse

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn