Question

I am new to Oracle. There is a requirement in our firm for a project using Oracle and .Net. So I was trying to run a demo application. I am using Oracle 10g XE as DB and VS2010.

I wrote a procedure with a simple select query, which got compiled (got this procedure format by googling).

The procedure, which got compiled

I ran the stored procedure from the SQL command prompt from XE Dashboard itself. This was the result:

enter image description here

Now I wrote code in C# to call that stored procedure:

string sqlCon = "Data Source=xe;Persist Security Info=True;User     ID=sa;Password=password;Unicode=True;Provider=OraOLEDB.Oracle;";
OleDbConnection Con = new OleDbConnection(sqlCon);
OleDbCommand cmd = new OleDbCommand();

DataSet ds = null;
OleDbDataAdapter adapter;

try
{
    Con.Open();
    ////Stored procedure calling. It is already in sample db.
    cmd.CommandText = "TESTPROC";
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Connection = Con;

    ds = new DataSet();
    adapter = new OleDbDataAdapter(cmd);
    adapter.Fill(ds, "Users");

    return ds.Tables[0];
 }
 catch (Exception ex)
 {
    throw new Exception(ex.Message);
 }

This code block didn't throw any exceptions. It got executed but what I received was an empty Dataset. But when I tried to fetch data using the query directly I got the result.

So, is the way I am trying to access the stored procedure correct? or Is there any mistake in my stored procedure? Can anyone point out the error or the best way to do this?

Thanks in advance.

Was it helpful?

Solution

Suggestion: try declaring "result" as an "out" parameter:

Here's one other link that might help:

OTHER TIPS

There is another link that might help:

http://www.akadia.com/services/ora_return_result_set.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top