| 主機參考: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測評,主機測評,云服務器,虛擬主機,獨立服務器,國內外服務器,高性價比建站主機相關優惠信息@m.k2270.com
詳細介紹和測評國外VPS主機,云服務器,國外服務器,國外主機的相關優惠信息,商家背景,網絡帶寬等等,也是目前國內最好的主機云服務器VPS參考測評資訊優惠信息分享平臺
這幾篇文章你可能也喜歡:
- inMotion.hosting:虛擬主機/VPS/經銷商主持人黑色星期五促銷活動,虛擬主機套餐每月$ 2.29
- Hostinger綜合審查(Hostdare如何可用)
- 藍色Xiyun香港AMD服務器4內核4G 19.9/月8核8G 39/月16核心16G 79/月,相同的價格更新價格
- HOSTDARE US虛擬托管在第一個月起為0.03美元(US Virtual IP)
- 網站服務器和虛擬主機有什么區別? (虛擬主機和虛擬服務器)
本文由主機參考刊發,轉載請注明:SQL Server 預編譯執行SQLs http://m.k2270.com/12628.html
主機參考

















評論前必須登錄!
注冊