首页  >  文章  >  数据库  >  置顶 后台执行两条SQL语句

置顶 后台执行两条SQL语句

WBOY
WBOY原创
2016-06-07 17:39:16850浏览

置顶 后台执行两条SQL语句 private void toTop( int pEC_TempID) { int mEC_TempID = 0; object oEC_TempID = myShare.GetAObject( true , 0, "EC_TempID" , "ElectronCards_temp" , "VendorID=" + ViewState[ "VendorID" ].ToString() + " and WebSiteType=

置顶 后台执行两条SQL语句

private void toTop(int pEC_TempID) { int mEC_TempID = 0; object oEC_TempID = myShare.GetAObject(true, 0, "EC_TempID", "ElectronCards_temp", "VendorID=" + ViewState["VendorID"].ToString() + " and WebSiteType=" + ViewState["WebSiteTypeID"].ToString()); if (oEC_TempID != null) { mEC_TempID = int.Parse(oEC_TempID.ToString()); }  SqlConnection con = null; bool flag = false; try { con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]); string sql1 = "update ElecProducts_Temp set DisplayOrder = case when DisplayOrder=255 then DisplayOrder else DisplayOrder+1 end where EC_TempID = "+mEC_TempID; string sql2 = "update ElecProducts_Temp set DisplayOrder=1 where EP_TempID=" + pEC_TempID; con.Open(); SqlCommand com = new SqlCommand(sql1, con); flag = com.ExecuteNonQuery() > 0 ? true : false; SqlCommand com2 = new SqlCommand(sql2, con); flag = com2.ExecuteNonQuery() > 0 ? true : false; con.Close(); } catch (SqlException se) { } finally { con.Close(); } if (flag) { myShare.WebMessageBox(this.Page, "置顶成功!"); int mECP_TempID = Convert.ToInt32(myShare.GetAObject(true, 0, "EC_TempID", "ElectronCards_temp", "VendorID=" + ViewState["VendorID"].ToString() + " and WebSiteType=" + ViewState["WebSiteTypeID"].ToString())); BindToDataList(mECP_TempID); } else { myShare.WebMessageBox(this.Page, "置顶信息时出错,请重试!"); } }

posted on

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

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn