Connecting Tech Pros Worldwide Forums | Help | Site Map

how to execute oracle stored procedure in C#

Newbie
 
Join Date: Aug 2008
Location: hyderabad-india
Posts: 18
#1: Jun 11 '09
Hi

I was struck up with big problem of executing a oracle stored procedure in C#.

Inputs 1:I am having 1 oracle stored procedure eg. myProc() and this procedure takes 1 INOUT parameter. of type stirng/varchar
problem description: I am not able to execute this procedure through my C# code.

for more information, below is the C# code that i am using......
Expand|Select|Wrap|Line Numbers
  1. OracleConnection con = new OracleConnection(StrConnectionString);
  2. con.Open();
  3. OracleCommand cmd = new OracleCommand("sapncdb.encrypt_field", con);
  4.       cmd.CommandType = CommandType.StoredProcedure;
  5. OracleParameter inval = new OracleParameter("inval", OracleType.VarChar);
  6.       inval.Direction = ParameterDirection.InputOutput;
  7. inval.Value = "13-4186423     ";
  8. cmd.Parameters.Add(inval);
  9. cmd.ExecuteNonQuery();
  10. Response.Write("return value is "+ inval.Value);
  11.  
Please help me out in getting the procedure execute in my C# code.

thanks in advance
Raj

PRR PRR is offline
Moderator
 
Join Date: Dec 2007
Location: India
Posts: 702
#2: Jun 12 '09

re: how to execute oracle stored procedure in C#


Are you getting any errors? did you try to execute your stored procedure from query analyzer (equivalent in Oracle )...
Link
Newbie
 
Join Date: Aug 2008
Location: hyderabad-india
Posts: 18
#3: Jun 16 '09

re: how to execute oracle stored procedure in C#


Hi DeepBlue

Thanks for your reply.

Ya i am able to execute the same procedure from sql prompt.

and while executing from stored procedure i am getting below error message

ORA-06550: line 1, column 15:
PLS-00905: object SAPNCDB.ENCRYPT_FIELD is invalid
ORA-06550: line 1, column 7:

where SAPNCDB.ENCRYPT_FIELD is my stored procedure name


did u find any mistake in my code of executing the stored procedure? if so plz let me know.

Thanks in advance....

Raj
Newbie
 
Join Date: Aug 2008
Location: hyderabad-india
Posts: 18
#4: Jun 16 '09

re: how to execute oracle stored procedure in C#


Hi All

Now i am able to execute my stored procedure.

I found the exact problem. and it is giving schema name before stored procedure name in command text.

i removed schema and executed and worked fine.

Thank you one and all for giving your valuabel solutions.

Regards
Raj
Reply

Tags
c# code, oracle, stored procedure