开发者

Getting the results from a stored procedure in Web Matrix

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜