Home > Database > Mysql Tutorial > 引用MySQL使用基于Parameter方式代码,总是提示:“Column '列名_MySQL

引用MySQL使用基于Parameter方式代码,总是提示:“Column '列名_MySQL

WBOY
Release: 2016-06-01 13:29:25
Original
1371 people have browsed it

bitsCN.com

引用MySQL使用基于Parameter方式代码,总是提示:“Column '列名'cannot be null”解决

 

MySQL使用基于Parameter方式代码,总是提示:“Column '列名' cannot be null”

 

解决方法1:直接在连接字符串里面加一个 oldsyntax=true  即可。

 

例如:

server=127.0.0.1;user id=root;password=;database=itemdb;oldsyntax=true
Copy after login

解决方法2:将语句中的 @ 替换为 ?

例如:

StringBuilder strSql=new StringBuilder();strSql.Append("insert into test(");strSql.Append("name)");strSql.Append(" values (");strSql.Append("?name)");MySqlParameter[] parameters = {  new MySqlParameter("?name", MySqlDbType.VarChar,45)};parameters[0].Value = model.name;DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
Copy after login

 


bitsCN.com
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template