Home  >  Article  >  Database  >  置顶 后台执行两条SQL语句

置顶 后台执行两条SQL语句

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

置顶 后台执行两条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: 博客园 模板提供:沪江博客

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