Retrieving results from a stored procedure in a web matrix

How do you get stored procedure results in WebMatrix? db.Execute only gives me the result code int, and db.Query does not find the column name in the results.

+3
source share
1 answer

The database assistant uses CommandType by default, which is CommandType.Text. It is not possible to change this to CommandType.StoredProcedure, so you need to use the following syntax:

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

The WebMatrix target audience is not aware of stored procedures. But you can always use simple ADO.NET and populate a strongly typed object through SqlDataReader. Or Entity Framework ....

+5
source

Source: https://habr.com/ru/post/1785949/


All Articles