Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

SQL Server precompilation executes SQLs

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Problem description:

MVC5 project, get the data by executing sql, but report an error when using precompile execution, field XXXwhich was not supplied.

In fact, it is this parameter that passes a null. Make a judgment before passing the parameter. If it is null, you can assign it to an empty string.

(=

String sql = "select a.ID matchingId Where a.DepId a. UserNameMagnea.TrueNamePowerISNull (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 (sql, sqlParameters). ToList ()

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report