469,269 Members | 1,006 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,269 developers. It's quick & easy.

Calling Oracle Stored Procedure from c#.net 2.0

Hi
I have following code and problem in calling the oracle stored procedure "DEPTREE_FILL"


Here is the Code:

Command.Connection = connection;
Command.CommandText="deptree_fill".ToUpper();
Command.CommandType = CommandType.StoredProcedure;

OracleParameter par1 = new OracleParameter("objectType", OracleType.Char);
par1.Direction = ParameterDirection.Input;
par1.DbType = DbType.String;
par1.Value = new OracleString(objectType); Command.Parameters.Add(par1);

OracleParameter par2 = new OracleParameter("objectOwner", OracleType.Char);
par2.Direction = ParameterDirection.Input;
par2.DbType = DbType.String;
par2.Value = new OracleString(objectOwner); Command.Parameters.Add(par2);

OracleParameter par3 = new OracleParameter("objectName", OracleType.Char);
par3.Direction = ParameterDirection.Input;
par3.DbType = DbType.String;
par3.Value = new OracleString(objectName); Command.Parameters.Add(par3);

OracleParameter par4 = new OracleParameter("out", OracleType.Number);
par4.Direction = ParameterDirection.Output;
par4.DbType = DbType.VarNumeric;
Command.Parameters.Add(par4);

Command.ExecuteNonQuery();



Here is the error message:

ORA-06550: LINE1,COLUMN7;
PLS-00306:WRONG NUMBER OR TYPES OF ARGUMENTS IN CALL TO
"DEPTREE_FILL"
ORA-06550:LINE1, COLUMN7;
PL/SQL:STATEMENT IGNORED
Jun 7 '07 #1
3 8089
debasisdas
8,127 Expert 4TB
Hi
muhammad
Welcome to TSDN.

You have reached the right place for knowledge shairing.

Here you will find a vast resource of related topics and code.

Feel free to post more doubts/questions in the forum.

But before that give a try from your side and if possible try to post what/how you have approached to solve the problem.

It will help Experts in the forum in solving/underestanding your problem in a better way.


Please follow posting guidelines and use code tags to make your post more readable.


It seems yout C# code is ok
but what bout the procedure in oracle.
Is it compiled with out error.

Can you please post the code of the PROCEDURE for my reference.
Jun 7 '07 #2
You can use template code the following such as:
Expand|Select|Wrap|Line Numbers
  1.  
  2. public int SG_SEG_GROUP_INSERT(SG_SEG_GROUP Entity)
  3.         {
  4.             int intResult = 1;
  5.             try
  6.             {
  7.  
  8.                 OracleParameter OraParm;
  9.                 OracleConnection DbConn = GetOracleConnection(strOrcConnection);
  10.                 OracleCommand OraCmd = new OracleCommand(PRO_SG_SEG_GROUP_INSERT, DbConn);
  11.                 OraCmd.CommandType = CommandType.StoredProcedure;
  12.  
  13.                 OraParm = new OracleParameter(PARAM_GRP_TP_ID_SRC, OracleType.VarChar, 64);
  14.                 OraParm.Direction = ParameterDirection.Input;
  15.                 OraParm.Value = Entity.GRP_TP_ID_SRC;
  16.                 OraCmd.Parameters.Add(OraParm);
  17.  
  18.                 OraParm = new OracleParameter(PARAM_GRP_CODE, OracleType.VarChar, 20);
  19.                 OraParm.Direction = ParameterDirection.Input;
  20.                 OraParm.Value = Entity.GRP_CODE;
  21.                 OraCmd.Parameters.Add(OraParm);
  22.  
  23.                 OraParm = new OracleParameter(PARAM_GRP_NM, OracleType.VarChar, 64);
  24.                 OraParm.Direction = ParameterDirection.Input;
  25.                 OraParm.Value = Entity.GRP_NM;
  26.                 OraCmd.Parameters.Add(OraParm);
  27.  
  28.                 OraParm = new OracleParameter(PARAM_DSC, OracleType.VarChar, 255);
  29.                 OraParm.Direction = ParameterDirection.Input;
  30.                 OraParm.Value = Entity.DSC;
  31.                 OraCmd.Parameters.Add(OraParm);
  32.  
  33.                 DbConn.Open();
  34.                 OraCmd.ExecuteNonQuery();
  35.                 DbConn.Dispose();
  36.             }
  37.             catch (Exception ex)
  38.             {
  39.                 intResult = -1;
  40.             }
  41.             return intResult;
  42.         }
  43.  
Oct 9 '10 #3
Expand|Select|Wrap|Line Numbers
  1. public int SG_SEG_GROUP_INSERT(SG_SEG_GROUP Entity)
  2.         {
  3.             int intResult = 1;
  4.             try
  5.             {
  6.  
  7.                 OracleParameter OraParm;
  8.                 OracleConnection DbConn = GetOracleConnection(strOrcConnection);
  9.                 OracleCommand OraCmd = new OracleCommand(PRO_SG_SEG_GROUP_INSERT, DbConn);
  10.                 OraCmd.CommandType = CommandType.StoredProcedure;
  11.  
  12.                 OraParm = new OracleParameter(PARAM_GRP_TP_ID_SRC, OracleType.VarChar, 64);
  13.                 OraParm.Direction = ParameterDirection.Input;
  14.                 OraParm.Value = Entity.GRP_TP_ID_SRC;
  15.                 OraCmd.Parameters.Add(OraParm);
  16.  
  17.                 OraParm = new OracleParameter(PARAM_GRP_CODE, OracleType.VarChar, 20);
  18.                 OraParm.Direction = ParameterDirection.Input;
  19.                 OraParm.Value = Entity.GRP_CODE;
  20.                 OraCmd.Parameters.Add(OraParm);
  21.  
  22.                 OraParm = new OracleParameter(PARAM_GRP_NM, OracleType.VarChar, 64);
  23.                 OraParm.Direction = ParameterDirection.Input;
  24.                 OraParm.Value = Entity.GRP_NM;
  25.                 OraCmd.Parameters.Add(OraParm);
  26.  
  27.                 OraParm = new OracleParameter(PARAM_DSC, OracleType.VarChar, 255);
  28.                 OraParm.Direction = ParameterDirection.Input;
  29.                 OraParm.Value = Entity.DSC;
  30.                 OraCmd.Parameters.Add(OraParm);
  31.  
  32.                 DbConn.Open();
  33.                 OraCmd.ExecuteNonQuery();
  34.                 DbConn.Dispose();
  35.             }
  36.             catch (Exception ex)
  37.             {
  38.                 intResult = -1;
  39.             }
  40.             return intResult;
  41.         }
Oct 9 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by stephane.traumat | last post: by
1 post views Thread by Jason Leiser | last post: by
1 post views Thread by Jim Heavey | last post: by
1 post views Thread by burtonl | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.