1 try 2 { 3 DBUtility.CommandInfo dbcom = new DBUtility.CommandInfo(); 4 List<DBUtility.CommandInfo> strStranList = new List<DBUtility.CommandInfo>(); 5 6 StringBuilder strSql = new StringBuilder(); 7 strSql.Append("Update Jia72_Members Set "); 8 strSql.Append("[email protected],"); 9 strSql.Append("[email protected],"); 10 strSql.Append("[email protected],"); 11 strSql.Append("[email protected],"); 12 strSql.Append("[email protected],"); 13 strSql.Append("[email protected],"); 14 strSql.Append("[email protected],"); 15 strSql.Append("[email protected]"); 16 strSql.Append(" Where [email protected] "); 17 string strSQLM = strSql.ToString(); 18 19 SqlParameter[] parameters = { 20 new SqlParameter("@Id",SqlDbType.Int,4), 21 new SqlParameter("@UserName",SqlDbType.NVarChar,20), 22 new SqlParameter("@YTCardId",SqlDbType.Int,4), 23 new SqlParameter("@CardNum",SqlDbType.NVarChar,20), 24 new SqlParameter("@Bank",SqlDbType.NVarChar,50), 25 new SqlParameter("@BankNumber",SqlDbType.NVarChar,32), 26 new SqlParameter("@QQNumber",SqlDbType.NVarChar,50), 27 new SqlParameter("@RealName",SqlDbType.NVarChar,10), 28 new SqlParameter("@SavedOn",SqlDbType.DateTime) 29 }; 30 parameters[0].Value = model.Id; 31 parameters[1].Value = model.UserName; 32 parameters[2].Value = model.YTCardId; 33 parameters[3].Value = model.CardNum; 34 parameters[4].Value = model.Bank; 35 parameters[5].Value = model.BankNumber; 36 parameters[6].Value = model.QQNumber; 37 parameters[7].Value = model.RealName; 38 parameters[8].Value = model.SavedOn; 39 40 dbcom.CommandText = strSql.ToString(); 41 dbcom.Parameters = parameters; 42 strStranList.Add(dbcom);//绑定会员信息 43 44 //更新卡表 45 strSql.Clear(); 46 strSql.Append("update Jia72_YTCard set "); 47 strSql.Append("IsBind=1,"); 48 strSql.Append("SavedOn=getdate()"); 49 strSql.Append(" where Id=" + model.YTCardId); 50 51 dbcom.CommandText = strSql.ToString(); 52 dbcom.Parameters = null; 53 strStranList.Add(dbcom);//更新卡表绑定 54 55 if (DBUtility.DbHelperSQL.ExecuteSqlTran(strStranList) > 0) 56 { 57 DotNet.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "UserManages.aspx"); 58 } 59 else 60 { 61 MessageBox.Show(this, "操作失败,请联系管理员!"); 62 } 63 } 64 catch (Exception ex) 65 { 66 LogHelper.WriteWebExLogInfo(this, ex); 67 MessageBox.Show(this, "操作失败,请联系管理员!"); 68 return; 69 }
说明:引用 DBUtility 用CommandInfo组织参数!还得用SQLHelper,悲催呀!
时间: 2024-10-12 13:33:43