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....
精彩评论