【发布时间】:2023-03-21 05:25:01
【问题描述】:
我需要 All Dapper master 的帮助。
我从一个月前开始学习使用 Dapper,但是在使用 ODBC SP 执行查询时出现错误。
代码最初是由某人(DapperExample)编写的,但没有使用 ODBC,感谢作者我忘记了你的名字。
我的 SP:
创建过程 SP_GET_FIND_EMPLOYEES (@EmpID INT) 作为 开始 设置无计数; SELECT * FROM tblEmployee WHERE EmpID = @EmpID
结束 去吧
我的代码
公共类 EmployeeDashBoard : IEmployeeDashBoard {
private IDbConnection _db;
string connStr2 = WebConfigurationManager.ConnectionStrings["DapperExample"].ConnectionString;
public EmployeeDashBoard()
{
}
public Employee Find(int id)
{
//type b, by sp
using (IDbConnection connection = new OdbcConnection(connStr2))
{
var p = new DynamicParameters();
p.Add("@EmpID", id);
Employee result = this._db.Query<Employee>("dbo.SP_GET_FIND_EMPLOYEES", new { @EmpID = id }, commandType: CommandType.StoredProcedure).Single();
return result;
}
}
}
错误:
错误 [42000] [Microsoft][SQL Server Native Client 11.0][SQL Server]过程或函数“SP_GET_FIND_EMPLOYEES”需要参数“@EmpID”,但未提供。
提前致谢。
马萨西赫
【问题讨论】: