时间:2021-07-01 10:21:17 帮助过:2人阅读
public static long CreateIntegralPay(long memId, decimal payAmount, decimal buyIntegral) { var id = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0); var sqlBuffer = new StringBuilder(); sqlBuffer.AppendLine("insert into `memberintegralrecordpay` (`Id`,`MemberId`,`PayType`,`PayAmount`,`BuyIntegral`,`PayStatus`,`RecordTime`,`Remark`)"); sqlBuffer.AppendLine("values(@Id, @MemberId, @PayType, @PayAmount, @BuyIntegral, @PayStatus, @RecordTime, @Remark);"); //sqlBuffer.AppendLine("select @@identity; "); const int val= 0; var sqlParameters = new MySql.Data.MySqlClient.MySqlParameter[] { new MySql.Data.MySqlClient.MySqlParameter("@Id",id), new MySql.Data.MySqlClient.MySqlParameter("@MemberId",memId), new MySql.Data.MySqlClient.MySqlParameter("@PayType", 0), new MySql.Data.MySqlClient.MySqlParameter("@PayAmount", payAmount), new MySql.Data.MySqlClient.MySqlParameter("@BuyIntegral",buyIntegral), new MySql.Data.MySqlClient.MySqlParameter("@PayStatus",val), new MySql.Data.MySqlClient.MySqlParameter("@RecordTime",DateTime.Now), new MySql.Data.MySqlClient.MySqlParameter("@Remark",string.Empty) }; if (DbHelper.ExecuteSql(sqlBuffer.ToString(), sqlParameters) > 0) { return id; } return 0; }
将0用变量代替后没有问题
public static long CreateIntegralPay(long memId, decimal payAmount, decimal buyIntegral) { var id = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0); var sqlBuffer = new StringBuilder(); sqlBuffer.AppendLine("insert into `memberintegralrecordpay` (`Id`,`MemberId`,`PayType`,`PayAmount`,`BuyIntegral`,`PayStatus`,`RecordTime`,`Remark`)"); sqlBuffer.AppendLine("values(@Id, @MemberId, @PayType, @PayAmount, @BuyIntegral, @PayStatus, @RecordTime, @Remark);"); //sqlBuffer.AppendLine("select @@identity; "); int val = 0; var sqlParameters = new MySql.Data.MySqlClient.MySqlParameter[] { new MySql.Data.MySqlClient.MySqlParameter("@Id",id), new MySql.Data.MySqlClient.MySqlParameter("@MemberId",memId), new MySql.Data.MySqlClient.MySqlParameter("@PayType", val), new MySql.Data.MySqlClient.MySqlParameter("@PayAmount", payAmount), new MySql.Data.MySqlClient.MySqlParameter("@BuyIntegral",buyIntegral), new MySql.Data.MySqlClient.MySqlParameter("@PayStatus",val), new MySql.Data.MySqlClient.MySqlParameter("@RecordTime",DateTime.Now), new MySql.Data.MySqlClient.MySqlParameter("@Remark",string.Empty) }; if (DbHelper.ExecuteSql(sqlBuffer.ToString(), sqlParameters) > 0) { return id; } return 0; }
MySql 参数赋值bug (MySql.Data, Version=6.9.6.0 沙雕玩意)
标签:parameter exec rem help values select color mem 数值