The data reader has more than one field error while calling a procedure that returns an integer

.net c# entity-framework sql-server

Popular Answer

Database.SqlQuery<T>() expecting a specific set of results, such asSELECT It operates on DbCommand.ExecuteReader() internally, and whenT is scalar, it anticipates the result set to contain precisely one field; but, if the result set has many fields, such as or if none are available, it throws the error you experienced.

By passing a, the return value can be obtained.DbParameter as seen in these instances, setting Database.SqlQuery<T>() and Direction = ParameterDirection.ReturnValue respectively:


ExecuteSqlCommand with a should be used if you only want the return value and not a result set.DbParameter .

8
5/23/2017 12:26:07 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow