MySql 参数赋值bug (MySql.Data, Version=6.9.6.0 沙雕玩意)
直接将参数赋值为常量0则参数值为null,出现异常:MySql.Data.MySqlClient.MySqlException (0x80004005): Column 'PayType' cannot be null
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 沙雕玩意)的更多相关文章
- 发布后台接口报错:could not load file or assembly 'mysql.data,' version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d
本地调试正常,但是服务器上面一直报错:could not load file or assembly 'mysql.data,' version=6.7.4.0, Culture=neutral, P ...
- MySQL程序之mysql参数详解
MySQL程序之mysql参数详解 mysql 是一个命令行客户程序,用于交互式或以批处理模式执行SQL语句 用法: mysql [OPTIONS] [database] 参数: 1.-? --hel ...
- 关于MySQL参数,这些你要知道
前言: 在前面一些文章中,经常能看到介绍某某参数的作用,可能有些小伙伴仍搞不清楚 MySQL 参数是啥.本篇文章我们来聊聊 MySQL 参数,学习下如何管理维护 MySQL 参数. 1.MySQL参数 ...
- MySQL参数文件及参数修改方法
MySQL参数文件: MySQL数据库初始化参数由参数文件来设置,如果没有设置参数文件,mysql就按照系统中参数的默认值来启动. 在windows和linux上,参数文件可以被放在多个位置,数据库启 ...
- mysql小白系列_02 mysql源码安装标准化
问题: 1.为什么数据目录和日志目录需要分开? 2.如何标准化配置多实例?(例如:一台物理主机上部署3306与3307两个实例) 3.详细描述MySQL编译安装的过程(截图安装步骤) 1.为什么数据目 ...
- 官方推荐的MySQL参数设置值
这oracle官方推荐的在OLTP环境下,MySQL参数设置的最佳实践. 下面的参数设置,对系统的性能会很有帮助.但是建议大家还是结合实际情况使用. APPLIES TO: MySQL Server ...
- 关于参数net_buffer_length How MySQL Uses Memory
http://dev.mysql.com/doc/refman/5.6/en/memory-use.html The following list indicates some of the ways ...
- MySQL参数调优最佳实践
前言很多时候,RDS用户经常会问如何调优RDS MySQL的参数,为了回答这个问题,写一篇blog来进行解释: 哪一些参数不能修改,那一些参数可以修改:这些提供修改的参数是不是已经是最佳设置,如何才能 ...
- MySQL DBA教程:Mysql性能优化之缓存参数优化
在平时被问及最多的问题就是关于 MySQL 数据库性能优化方面的问题,所以最近打算写一个MySQL数据库性能优化方面的系列文章,希望对初中级 MySQL DBA 以及其他对 MySQL 性能优化感 ...
随机推荐
- lua 的 cjson 安装,使用
1. 背景: 虚拟机安装的luajit 没有 cjson 库,就不能对 table 进行 编码操作,手动安装一个. 2. 安装: cjson下载地址:http://www.kyne.com.au/~ ...
- Python元组与字符串操作(8)——三数排序多种实现
练习 依次接收用户输入的3个数,排序后打印 1.转换int后,判断大小排序,使用分支结构完成 num1 = [] for i in range(3): num1.append(int(input('& ...
- AssetBundleMaster_Introduce_EN
This is an integrated solution for building AssetBundles and loading Assets. what it can do is about ...
- C语言之++和--
#include<stdio.h> int main(void) { int a; a = ; printf("a++ = %d\n", a++); printf(&q ...
- 201871010124-王生涛《面向对象程序设计(java)》第十四周学习总结
项目 内容 这个作业属于哪个课程 <任课教师博客主页链接>https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 <作业链接地址>http ...
- echo和printf打印输出
[root@node2 scprits]# echo Hello World! Hello World! [root@node2 scprits]# echo 'Hello World!' Hello ...
- Spring Cloud Alibaba Sentinel 的配置选项:spring.cloud.sentinel.transport.port,默认值:8719
spring.cloud.sentinel.transport.port 端口配置会在应用对应的机器上启动一个 Http Server,该 Server 会与 Sentinel 控制台做交互.比如 S ...
- java中判断两个对象是否相等
package ceshi.com.job; import java.util.ArrayList; import java.util.Arrays; import java.util.List; p ...
- zz深度学习论文合集大全
Pull requestsIssues Marketplace Explore Learn Git and GitHub without any code! Using ...
- Python DataFrame 按条件筛选数据
原始数据如下. 比如我想查看id等于11396的数据. pdata1[pdata1['id']==11396] 查看时间time小于25320的数据. pdata1[pdata1['time']< ...