主机参考:VPS测评参考推荐/专注分享VPS服务器优惠信息!若您是商家可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情! |
我们发布的部分优惠活动文章可能存在时效性,购买时建议在本站搜索商家名称可查看相关文章充分了解该商家!若非中文页面可使用Edge浏览器同步翻译!PayPal代付/收录合作 |
问题描述:
MVC5项目,利用执行sql的方式获取数据,但是在利用预编译执行的时候报错了,字段XXXwhich was not supplied.
其实就是这个参数传了个null导致的。在传参数之前做个判断,如果为null就赋值为空串即可。
(=
String sql = "select a.Id,a.UserName,a.TrueName,ISNULL(b.OTM, '0') as Flag from SysUser a left join FIX_MatchingModel b on cast(a.Id as varchar) = b.OTM and b.Id = @matchingId Where a.DepId = @DepId order by b.OTM desc";SqlParameter[] sqlParameters = { new SqlParameter { ParameterName = "matchingId", Value = matchingId }, new SqlParameter { ParameterName = "DepId", Value = depId } };DbContexts DbContext = new DbContexts();return DbContext.Database.SqlQuery<UserViewgt;(sql, sqlParameters).ToList();
Problem Description:
Mvc5 project, uses the method of executing SQL to obtain data, but reports an error when using precompiled execution, field xxxwhich was not supplied
In fact, this parameter passed a null. Make a judgment before passing the parameter. If it is null, it can be assigned as an empty string.
(=
String sql = "select a.Id,a.UserName,a.TrueName,ISNULL(b.OTM, '0') as Flag from SysUser a left join FIX_MatchingModel b on cast(a.Id as varchar) = b.OTM and b.Id = @matchingId Where a.DepId = @DepId order by b.OTM desc";SqlParameter[] sqlParameters = { new SqlParameter { ParameterName = "matchingId", Value = matchingId }, new SqlParameter { ParameterName = "DepId", Value = depId } };DbContexts DbContext = new DbContexts();return DbContext.Database.SqlQuery<UserViewgt;(sql, sqlParameters).ToList();
--------------------------------------------------------------
主机参考,收集国内外VPS,VPS测评,主机测评,云服务器,虚拟主机,独立服务器,国内外服务器,高性价比建站主机相关优惠信息@zhujicankao.com
详细介绍和测评国外VPS主机,云服务器,国外服务器,国外主机的相关优惠信息,商家背景,网络带宽等等,也是目前国内最好的主机云服务器VPS参考测评资讯优惠信息分享平台
这几篇文章你可能也喜欢:
- Megalayer,新加坡独立服务器特价优惠低至399元/月,优化/国际化线路可选,原生IP/DDOS防御/组内网支持
- ReliableSite,美国便宜高防服务器特价优惠低至$75/月,免费20G DDOS防御,美国洛杉矶/纽约/迈阿密,AMD Ryzen 5800X/64G内存/1Gbps带宽/不限流量
- 华纳云:200克香港高级防御服务器20M CN2 GIA高质量带宽9999 yuan/月,DDOS/CC忽略了
- Sharktech,美国高防御高配置大带宽不限流量服务器特价优惠,60G防御/10Gbps带宽/不限流量,最高1T内存/40Gbps带宽/1T防御,洛杉矶/拉斯维加斯
- 美国休斯顿CharityHost大内存VPS提供双倍流量:1核3G/100GB SSD/10TB月流量/1Gbps/1 IPv4/1 IPv6/3.5 USD/月
本文由主机参考刊发,转载请注明:SQL Server 预编译执行SQLs https://zhujicankao.com/12628.html
评论前必须登录!
注册