我在Oracle和.NET中遇到了一个非常罕见的问题,我有一个简单的选择,可以检索产品列表,它可以正常工作。但是,使用存储过程,它似乎不执行它,但它没有说明任何错误或参数缺失。它在SQL Developer中运行时可以正常工作。
OracleCommand ora_cmd = new OracleCommand("a6r1.PR_ABC_P_ALTA_TARJETA_PAYWARE", ora_conn);
ora_cmd.BindByName = true;
ora_cmd.CommandType = CommandType.StoredProcedure;
int exito = 0;
ora_cmd.Parameters.Add("Lc_Param_Issuer", OracleDbType.Varchar2, issuer, ParameterDirection.Input);
ora_cmd.Parameters.Add("Ln_Param_Valid_Product", OracleDbType.Varchar2, DropDownListProducto.SelectedValue.ToString(), ParameterDirection.Input);
ora_cmd.Parameters.Add("Ln_Param_Total", OracleDbType.Int32, Convert.ToInt32(TextBoxCantidad.Text) , ParameterDirection.Input);
ora_cmd.Parameters.Add("Lc_Param_User", OracleDbType.Varchar2, user, ParameterDirection.Input);
ora_cmd.Parameters.Add("Lc_Encrypted_Password", OracleDbType.Varchar2, pass, ParameterDirection.Input);
ora_cmd.Parameters.Add("Lc_Exito", OracleDbType.Int32, exito, ParameterDirection.Output);
/*********************Oracle Command**********************************************************************/
ora_cmd.ExecuteNonQuery();
SP太大而无法放在这里,所以我只会添加标题。
PROCEDURE PR_ABC_P_ALTA_TARJETA_PAYWARE (
Lc_Param_Issuer In Varchar2,
Ln_Param_Valid_Product In Varchar2,
Ln_Param_Total In Number,
Lc_Param_User In Varchar2,
Lc_Encrypted_Password In Varchar2,
Lc_Exito Out Number
)
感谢任何帮助或见解。
答案 0 :(得分:0)
试试这个:
using Oracle.DataAccess;
using Oracle.DataAccess.Client;
public DataTable ExecuteSP()
{
using (OracleConnection cn = new OracleConnection(GetConnectionString()))
{
OracleDataAdapter da = new OracleDataAdapter();
OracleCommand cmd = new OracleCommand();
cmd.Connection = cn;
cmd.CommandText = "PR_ABC_P_ALTA_TARJETA_PAYWARE";
cmd.CommandType = CommandType.StoredProcedure;
cmd.BindByName = true;
cmd.Parameters.Add("Lc_Param_Issuer", OracleDbType.Varchar2, issuer, ParameterDirection.Input);
cmd.Parameters.Add("Ln_Param_Valid_Product", OracleDbType.Varchar2, DropDownListProducto.SelectedValue.ToString(), ParameterDirection.Input);
cmd.Parameters.Add("Ln_Param_Total", OracleDbType.Int32, Convert.ToInt32(TextBoxCantidad.Text) , ParameterDirection.Input);
cmd.Parameters.Add("Lc_Param_User", OracleDbType.Varchar2, user, ParameterDirection.Input);
cmd.Parameters.Add("Lc_Encrypted_Password", OracleDbType.Varchar2, pass, ParameterDirection.Input);
cmd.Parameters.Add("Lc_Exito", OracleDbType.Int32, exito, ParameterDirection.Output);
cmd.Parameters.Add("T_CURSOR", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
}