-
Notifications
You must be signed in to change notification settings - Fork 861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
从1.3.5升级到1.7.0后报错,Ado.ExecuteNonQuery(CommandType.Text, stb.ToString(), paramList.ToArray()); #395
Comments
是不是 FreeSql.Provider.Sqlserver 1.6.0 会报错吗 1.7.0 换了 adonet 驱动包,Microsoft.Data.SqlClient |
是的, |
估计是跟改 adonet 驱动的机制有关,方便的话试下1.6.0 |
可能很 paramList 里面的值有关,看是不是有 null,应该改成 DbNull.Value |
好的,谢谢,我先试下,有结果通知您 |
我试了1.6.0的确是可以的, paramList中没有为null的 |
Microsoft.Data.SqlClient 这个是微软推荐的新库。必须要换的。 可以去他的 github 搜索错误描述,看有没有相关回复。 |
好的,谢谢 |
如果用 System.Data.SqlClient 执行命令时, 传入的 DbParameter 类型是 Microsoft.Data.SqlClient.SqlParameter 类型就会报这个错误。 例如在使用 System.Data.SqlClient 的实现中使用如下代码: fsql.Ado.Query<dynamic>(
System.Data.CommandType.Text,
"select * from xxx where Id = @Id",
new Microsoft.Data.SqlClient.SqlParameter("Id", 1)
); 另外,可以不使用具体的参数化类型传递,如下: fsql.Ado.Query<dynamic>(
"select * from xxx where Id = @Id",
new { id = 1 }
);
// 或者
fsql.Ado.Query<dynamic>(
"select * from xxx where Id = @Id",
new Dictionary<string, object> { ["id"] = 1 }
); |
感谢大佬,厉害啊 |
你好,
我从1.3.5升级到1.7.0后,Ado.ExecuteNonQuery(CommandType.Text, stb.ToString(), paramList.ToArray());这一句一直报错,paramList中是有值的,在1.3.5是运行正常的
报错内容:SqlParameterCollection only accepts non-null SqlParameter type objects, not DBNull objects
The text was updated successfully, but these errors were encountered: