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

置顶 后台执行两条SQL语句

程序员文章站 2022-05-16 16:46:34
...

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