.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Oracle stored procedure using parameters

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :ASP.Net

Hi, am having a problem sending parameters to the stored procedure, I'm not sure if i'm sending Oracle the parameters in the right way.

USING:oracle 11g x64, C#, ASP.net 4.0, ODP.NET


The header of the stored procedure on Oracle server is:


?PROCEDURE create_new_user(p_log_in_name IN VARCHAR2, p_password_text IN VARCHAR2, isSuccessful OUT NUMBER)


The code the use the stored procedure in C# asp.net:

       OracleConnection connect = new OracleConnection("User Id=xpcal;Password=password123;Data Source=ora11g;");
        OracleCommand command_create_user = new OracleCommand();

        command_create_user.Connection = connect;

        command_create_user.CommandText = "xpcal.xpcal_users.create_new_user";
        command_create_user.CommandType = CommandType.StoredProcedure;

        OracleParameter p_log_in_name1 = new OracleParameter();
        p_log_in_name1.OracleDbType = OracleDbType.Varchar2;
        p_log_in_name1.Direction = ParameterDirection.Input;
        p_log_in_name1.Value = tbox_user.Text;

        OracleParameter p_password = new OracleParameter();
        p_log_in_name1.OracleDbType = OracleDbType.Varchar2;
        p_log_in_name1.Direction = ParameterDirection.Input;
        p_log_in_name1.Value = tbo

View Complete Post

More Related Resource Links

c# code to create an array of parameters for oracle stored procedure



Working on a c# project that has oracle as backend.  I have problem creating a function in my codebehind page to create an array of paramenters for oracle stored procedure. for example i have the follwoing code for ms sql server...

SqlParameter[] parm = 


                         DataCon.createSqlParameter ("@id", DataCon.DBNullIfBlank(txtid.Text.ToString()), SqlDbType.Char,9 ) ,

                         DataCon.createSqlParameter ("@FName", DataCon.DBNullIfBlank(txtFName.Text.ToString()), SqlDbType.VarChar,14),

                         DataCon.createSqlParameter ("@MI", DataCon.DBNullIfBlank(txtMI.Text.ToString()), SqlDbType.Char,1),


 For the same in oracle I am using the followin

Trying to run a stored procedure from vb code with oracle data provider.



Here is my SP:

create or replace
 Open p_getuserssignon_recordset1 for
 SELECT Distinct(Userid), UserPassword, SecurityLevel, ActiveStatus
WHERE substr(UserId,1,2) <> vUid
Order By UserId;

I would like to run this SP from code and fill a gridview with the result. 

I am not sure how to go about this, as I have found several different examples, other than the one I  think I need.

I am using the oracle data provider and I have an input parameter (vUid, which will equal "zz").

First question. When filling a gridview with a result set from a stored procedure should the recordset OUT be defined as a REFCURSOR (like i did above)? 


Do you have example code as to how to execute the SP and fill a gridview?  I keep trying different variations of code i've found on the internet without any success other than getting more confused.

(I am using VS 2005, VB).

Thank you.



can a Workflow access a stored procedure and pass the parameters from the list data to the stored pr

The reason that I would like to consider this functionailty is because my table architecture is complicated and I do not want to modify my master table to accept all of this data where some of the data should be normalized into sub tables.  Has anyone see evidence of the stored-procedure parm approach?  Is this best accomplished through VS 2010 or can I do it through SPD? Thanks

SQL 2010 SP1 does not fill in Stored Procedure Parameters

I am executing a Stored Procedure in Server Management Studio.  The Procedure gives the expected results but it does not fill in the parameters?  I have stop and restarted the server to no avail. Please help? Thanks. STORED PROCEDURE USE   [char68003f] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[SelectDonorXiD] ( @DonorID varchar(50) , @ContactTitle varchar(7)=null OUTPUT, @ContactFirstName varchar(40)=null OUTPUT, @ContactLastName varchar(40)=null OUTPUT, @ContactAddress1 varchar(40)=null OUTPUT, @ContactAddress2 varchar(40)=null OUTPUT, @ContactCity varchar(30)=null OUTPUT, @ContactStateCode varchar(2)=null OUTPUT, @ContactZipCode varchar(10)=null OUTPUT, @ContactPhone varchar(30)=null OUTPUT, @ContactEmail varchar(80)=null OUTPUT, @BillingTitle varchar(7)=null OUTPUT, @BillingFirstName varchar(40)=null OUTPUT, @BillingLastName varchar(40)=null OUTPUT, @BillingAddress1 varchar(40)=null OUTPUT, @BillingAddress2 varchar(40)=null OUTPUT, @BillingCity varchar(30)=null OUTPUT, @BillingStateCode varchar(2)=null OUTPUT, @BillingZipCode varchar(10)=null OUTPUT, @BillingPhone varchar(30)=null OUTPUT, @BillingEmail varchar(80)=null OUTPUT ) AS Select ContactTitle, ContactFirstName, ContactLastName, ContactAddress1, ContactAddress2, ContactCity, ContactStateCode, ContactZipCode, ContactPhone, ContactEmail, BillingTitle, Bil

Capture Stored Procedure Parameters in Trace

Hi, I want to capture each execution of all stored procedures and the parameters supplied, I'm going to do this via a trace on RPC:starting, capturing TextData, Database and starttime. I'll need to parse the TextData column to get the information that I want. I assume I also need to capture nested stored procedure calls , i.e. SP: starting as well. Does this sound correct and is this the best way of extracting this information ?Sean

Entity Framework - stored procedure mapping, excecuting SP with float parameters separated by commas



Im using Entity framework with POCO entity generator template + SQL Server. I have mapping to stored procedure that takes two floats as input.

After executing function from code with two doubles as parameters: 1.23 and 4.56, SQL Profiler shows:

exec storedProcedureName @arg1 = 1,23, @arg2= 4,56

This is causing an error because it looks like that stored procedure takes 4 arguments, but it should take only two and there should be dots insted of commas in these floats.

My SQL Server collation is SQL_Latin1_General_CP1_CI_AS. I tried to set:

           Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
           Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

in DataContext Constructor, and di

Calling Oracle stored procedure


I am calling oracle procedure in SSIS script task, This stored procedure retrun value as output, I tried OLEDB it not working, Now i am trying using ADO.net connection, while executing task i am getting following error msg


[Execute SQL Task] Error: Executing the query "exec ssisproctes" failed with the following error: "Unable to cast object of type 'System.Data.OracleClient.OracleConnection' to type 'System.Data.SqlClient.SqlConnection'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

I am able to test connection in connection manager?

any help to resolve this issue, or is there any other method to call oracle procedure and get output value in a SSIS variable




Problem with Oracle Stored Procedure/Web Form(C#)



I receive the following message when trying to insert a record into a table via Web Form(C#):

Error: Invalid operation. Connection closed.

The button event, when clicked, should connect to the database and then call the stored procedure and
insert a new record according to the text input on the Web Form. Hence, returning the new flight id (TID).

Note: Some entries can be null.



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Add_Flight.aspx.cs" Inherits="Add_Flight" %>   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .style1 { width: 89%; } .style2 { height: 23px; } .style3 { width: 360px; } .style4 { width: 137px; } .style5 { height: 23px; width: 137px; } .style6 { width: 95px; } .style7 { height: 23px; width: 95px; } .style8 { width: 200px; } .style9 { width: 129px; } </style> </head> <body> <form id="form1" runat="server"> <div> <table cellspacing="3" class="styl

Pass Multi-Value parameters to Stored Procedure problem



I am trying to pass multi-value parameters to stored procedure to filter data, but seems it does not work.

Stored procedure:


ALTER PROCEDURE [dbo].[test]

@StartDate DateTime,
@EndDate DateTime,
@FirstName varchar(8000),
@LastName varchar(8000),
@Location varchar(8000),

SELECT [Item No_],[Sales Staff],[Location Code],[Date],
[Price],[Quantity],[Item Category Code],[Product Group Code]FROM [Trans Sales Entry]
cte2 as
SELECT [ID],[First Name],[Last Name] FROM Sta

JDBC - stored procedure won't allow setting parameters by name



When I try to call CallableStatement.setString( name, value ) it throws an exception. Is there something I have to do to either change the parameter names or set them up? I use the full "@Beginning_Date" as the name.

thanks - dave

Very funny video - What's your Metaphor?

Error passing parameters from C# to Stored Procedure



I have a Stored Procedure that receive a parameter.
- SP name: hr_all_markets
- SP parametter: @cs_rep (type varchar 50)
In my C# code I already called this SP without parameters and works fine, but when I try to run with parameters I have this error:
- Incorrect syntax near 'hr_all_markets'.

How do I call an SSRS Report from a stored procedure, and pass parameters?


Hi all,

I have a Report, that I want to run ad-hoc from a Stored Procedure. 

I want to render this report to PDF format, and save it to a drive.

The difference between this post and most threads I've seen is I don't want to run a stored proc within the report and send parameters to the stored proc.

I DO want to call a report FROM the stored proc, and send parameters TO the report.

How can I do this?

Many thanks,


Database Tuning Advisor, Stored Procedure with datetime parameters, syntax error


I receive these error(s) in the Tuning Log. I have several stored procedures and they all use a datetime parameter.

E000    exec <some sproc name> ''2009-01-01 00:00:00:000'',''2010-09-30 00:00:00:000'',N'',N'',NULL,NULL,NULL,NULL,NULL,NULL         1    [Microsoft][SQL Native Client][SQL Server]Incorrect syntax near '2009'.

I am using SQL 2005. Any suggestions?

Thanks, Reece

Creating BCS entity for a SQL stored procedure that has parameters using visual studio


Hi Everyone,

                 can anyone help me in creating  BCS entity using BCDM model in visual studio using Linq to sql query for a SQL stored procedure.I am receiving remote debugging error and few other errors.Your step by step approach helps me a lot,I have been playing with this for long,but still no answer.


Thanks ,

Selecting Oracle Stored Procedure in SSRS Crashes Visual Studio 2005 IDE


Problem Conditions

I have a very simple Oracle (11g) Stored Procedure that is declared like so:

* FROM MyTable;

This compiles correctly. The cursor contains col1, col2 and col3.

In SSRS, i have a Shared Data Source that uses Oracle OLEDB Provider for Oracle 11g:


How to call Oracle Stored Procedure which has an output parameter from SSIS?


I will really appreciate if someone can post step by step process to call an Oracle Stored Proc from SSIS. Here is the Stored Proc Spec:


    PROCEDURE Interface_Begin

    (p_from_dttm       OUT varchar2,

     p_error_code            OUT number,

     p_error_text       OUT            varchar2,

     p_proc_name        OUT varchar2);  


Help on Stored Procedure with multiple like parameters


Hi All,

Please go through the screenshot below.


I have a table with 4 columns.The first column is a list of teams.The other three columns specify whether the team member with the particular id is present on any particular day .Say for example in the third row the running Team has 2 and 3 which means team member with the id 2 and 3 are present.Multiple values are seperated by the pipe symbol '|'.

I have a Query like this

Select Teamname from tblTeam where Running not like '%|2|%' and Running not like '%|3|%' and Running not like '%|7|%' and Biking not like '%|1|%' and Biking not like '%|4|%' and Biking not like '%|7|%' and shooting not like '%|3|%' and shooting not like '%|4|%' and shooting not like '%|7|%'

Basically i am searching the columns with like clause.The search criteria for each column may vary.In the above query i am searching for Teams where Running column does not contain 2,3 and 7,Biking column does not contain 1,4 and 7 and the shooting column does not contain 3,4 and 7.

I would like to set a stored procedure where i would be able to pass 3 set of parameters from the code behind(I am using VB.net) for Running column sear

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend