从Oledb Connection调用Oracle函数

时间:2014-09-09 16:57:19

标签: c# sql oracle ado.net oledbcommand

您好我正在尝试使用以下代码调用Oracle函数,但它显示错误,如

  

" ORA-01403:未找到数据\ nORA-06512:在\" TEST.VOD_BULK_TRANS1 \",   第47行\ nORA-06512:第1行"

该函数接受3个输入参数并返回一个整数值。

using (OleDbConnection conn= new OleDbConnection(connectionString))
{
    conn.Open();

    //set the command text (stored procedure name or SQL statement)
    command.CommandText = "VOD_BULK_TRANS1";

    command.Parameters.Add(new OleDbParameter("retVal", OleDbType.VarChar, 11, ParameterDirection.ReturnValue, true, 0, 0, "retVal", DataRowVersion.Current,null));
    command.Parameters.Add( OleDbParameter("@t_list", videosListWithCommaSeparated);
    command.Parameters.Add( OleDbParameter("@option1", 3);
    command.Parameters.Add( OleDbParameter("@id1", groupId);
    command.ExecuteNonQuery();

}

请告诉我如何使用Oledb Conneciton调用函数或存储过程。

1 个答案:

答案 0 :(得分:0)

使用ado.net执行Stored Procedure时,必须将IDbCommand对象的CommandType属性设置为CommandType.StoredProcedure。样本:

using (OleDbConnection conn= new OleDbConnection(connectionString))
{
    conn.Open();

    // set the commend type here    
    command.CommandType = CommandType.StoredProcedure;

    //set the command text (stored procedure name or SQL statement)
    command.CommandText = "VOD_BULK_TRANS1";

    command.Parameters.Add(new OleDbParameter("retVal", OleDbType.VarChar, 11, ParameterDirection.ReturnValue, true, 0, 0, "retVal", DataRowVersion.Current,null));
    command.Parameters.Add( OleDbParameter("@t_list", videosListWithCommaSeparated);
    command.Parameters.Add( OleDbParameter("@option1", 3);
    command.Parameters.Add( OleDbParameter("@id1", groupId);
    command.ExecuteNonQuery();

}
相关问题