Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 WebMatrix 中获取存储过程的结果?db.Execute 只给我 int 结果代码,而 db.Query 在结果中找不到列名。
数据库助手使用默认的 CommandType,即 CommandType.Text。无法将其更改为 CommandType.StoredProcedure,因此您需要使用以下语法:
var data = db.Query("exec usp_MyProc @0, @1", "val1", val2");
假定 WebMatrix 的目标受众不了解存储过程。但是您始终可以使用普通的 ADO.NET 并通过 SqlDataReader 填充强类型对象。或者实体框架....