The OracleParameter with ParameterName 'pCursor' is already...

S

ScottStoecker

I am trying to return a cursor to a business layer object from a data
layer object and am receiving this message:

The OracleParameter with ParameterName 'pCursor' is already
contained by another OracleParameterCollection.

The data layer function I am using looks like this:

Public Function ReturnDataTable(ByVal CommandString As String,
ByVal Parameters As OracleClient.OracleParameterCollection) As
DataTable
Conn = OpenConnection()

Comm = New OracleCommand(CommandString, Conn)
Comm.CommandType = CommandType.StoredProcedure

For Each Param As OracleParameter In Parameters
Comm.Parameters.Add(Param)
Next

Adp = New OracleDataAdapter(Comm)
objDS = New DataSet
Adp.Fill(objDS, "Results")

CloseConnection(Conn)

Return objDS.Tables(0)
End Function

The error is occuring on the line Comm.Parameters.Add(Param). In the
business layer, I simply create an OracleParameter, add it to the
OracleParameterCollection, and pass the OracleParameterCollection as a
parameter to the function. The parameter in the business layer is
declared as OracleType.Cursor and the Direction is Output. I have seen
a few people ask this question, but no answers to it. Any ideas? I can
get around the problem by just calling the stored procedure that
returns the cursor directly from the business layer, but I would like
to know why the data layer is causing an error.

Thank you,
Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top