开发者

Getting the results from a stored procedure in Web Matrix

开发者 https://www.devze.com 2023-02-05 16:19 出处:网络
How do you get the results of a stored procedure in WebMatrix? 开发者_如何学运维 db.Execute is only giving me the int result code, and db.Query doesn\'t find the column name in the results.The Databas

How do you get the results of a stored procedure in WebMatrix? 开发者_如何学运维 db.Execute is only giving me the int result code, and db.Query doesn't find the column name in the results.


The Database helper uses the default CommandType, which is CommandType.Text. There is no way to change that to CommandType.StoredProcedure, so you need to use the following syntax:

var data = db.Query("exec usp_MyProc @0, @1", "val1", val2");

The target audience for WebMatrix are not assumed to know about stored procedures. But you can always use plain ADO.NET and populate a strongly typed object via a SqlDataReader. Or the Entity Framework....

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号