Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have stored proc which has one in parameter and one out parameter as follows:
SQL
create or replace procedure worker_name (w_id in number, w_first out worker.first_name%type) is

Begin
  select first_name into w_first
  from worker
  where worker_id = w_id;
end;


code to call this stored procedure:

public DataTable GetEmployeeName(int _employeeID)
        {
            ArrayList arrEmployeeName = new ArrayList();
            OracleParameter paramEmployeeId = new OracleParameter(":employeeid", _employeeID);
            arrEmployeeName.Add(paramEmployeeId);
            DataLayer obj = new DataLayer();
            DataTable tblEmployee = obj.GetData("macw_conv.worker_name", arrEmployeeName, "SP");
            if (tblEmployee.Rows.Count > 0)
            {
                return tblEmployee;
            }
            return null;
        }


public DataTable GetData(string query, ArrayList parameters,string queryType)
        {
            //DataTable dt = new DataTable();
            try
            {
                _con =
                    new OracleConnection(Oradb);
                _con.Open();
                _cmd = new OracleCommand(query, _con);
                if (_cmd.Connection.State == ConnectionState.Open)
                {
                    if (queryType == "SP" && parameters != null)
                    {
                        _cmd.CommandType = CommandType.StoredProcedure;
                        if (parameters.Count > 0)
                        {
                            foreach (OracleParameter param in parameters)
                            {
                                _cmd.Parameters.Add(param);
                            }
                        }
                    }
                }
                DataSet ds = new DataSet();
                OracleDataAdapter da = new OracleDataAdapter(_cmd);
                da.Fill(ds);
                if (ds.Tables.Count > 0)
                {
                    return ds.Tables[0];
                }
                return null;
            }


I guess i'm unable to see the obviuos error.Its something about the data type mismatch between the out parameter in the store proc and output parameter in the code. Any kind of help is appreciated.
Posted
Updated 3-Dec-12 10:45am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900