我正在尝试编写一些应该与DB无关的方法,以便可以使用相同的代码而不管DB(Oracle,SQL server)
我正在使用IDbConnection和IDbCommand接口。 在调用该过程时,它会给出错误,指出非法变量名称/数字错误。虽然我能够直接调用内联查询(直接将查询指定为命令文本) 这是示例电话..
using (IDbConnection connection = this._providerFactory.CreateConnection())
{
// create the command object using the conneciton object
IDbCommand command = connection.CreateCommand();
//start
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "GetResponse";
IDbDataParameter menuParam = this._providerFactory.CreateParameter();
menuParam.DbType = DbType.String;
menuParam.Direction = ParameterDirection.Input;
menuParam.ParameterName = "@V_USER_ID";
command.Parameters.Add(menuParam);
IDbDataParameter menuParam2 = this._providerFactory.CreateParameter();
menuParam2.Size = 20;
menuParam2.DbType = DbType.String;
menuParam2.Size = 20;
menuParam2.Direction = ParameterDirection.Output;
menuParam2.ParameterName = "@V_ROLE_ID";
menuParam2.Value = DBNull.Value;
command.Parameters.Add(menuParam2);
//end
command.ExecuteNonQuery();
}
答案 0 :(得分:0)
此处未提供任何值(并删除@符号):
IDbDataParameter menuParam = this._providerFactory.CreateParameter();
menuParam.DbType = DbType.String;
menuParam.Direction = ParameterDirection.Input;
menuParam.ParameterName = "V_USER_ID";
command.Parameters.Add(menuParam);