Click here to Skip to main content
14,600,878 members
Rate this:
Please Sign up or sign in to vote.
See more:

I have two database smart04 and smart02, I can connect smartt02 db successfully but the smart02 error is throwing error in the execute reader line. but I can see the connection is in open state.

Anyone please help me to fix this.
StackTrace = " at OracleInternal.ServiceObjects.OracleConnectionImpl.VerifyExecution(Int32& cursorId, Boolean bThrowArrayBindRelatedErrors,
SqlStatementType sqlStatementType, Int32 arrayBindCount, OracleException& exceptionForArrayBindDML, Boolean& hasMoreRowsInDB, Boolean bFirstIterationDone)\r\n
at OracleInternal.ServiceObjects.OracleCommandImpl.
ExecuteReader(String commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl,
OracleDataReaderImpl& rdrImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64[] scnForExecution,
Int64[]& scnFromExecution, OracleParameterCollection& bindByPositionParamColl, Boolean& bBindParamPresent, Int64& internalInitialLOBFS,
OracleException& exceptionForArrayBindDML, OracleConnection connection, OracleLogicalTransaction& oracleLogicalTransaction,
IEnumerable`1 adrianParsedStmt, Boolean isDescribeOnly, Boolean isFromEF)\r\n
at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)\r\n
at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteReader()\r\n

What I have tried:

SQLHelper conn = new SQLHelper();
                OracleConnection con = conn.GetConnectionString(dbname);

                OracleCommand cmd = new OracleCommand();
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = "XYZ";
                cmd.Connection = con;
                // cmd.ExecuteNonQuery();
                ConnectionState state = con.State;
                if (state == ConnectionState.Open)
                     var j = cmd.ExecuteReader();

                    string i = cmd.Parameters["val"].Value.ToString();

<add name="smart02" connectionstring="Data Source=  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = = 1521))
      (SERVICE_NAME = smart02) 
    ));user id=xxxx;password=yyyy;" providername="System.Data.OracleClient">

<add name="smart04" connectionstring="Data Source=  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = = 1521))
      (SERVICE_NAME = smart04) 
    ));user id=xxxx;password=yyyy;" providername="System.Data.OracleClient">
Updated 10-Jul-20 1:49am
Richard Deeming 10-Jul-20 7:07am
You've pasted the stack trace, but removed the actual error details.

Click the green "Improve question" link and update your question to include the full details of the exception.
Garth J Lancaster 10-Jul-20 21:01pm
It would also be handy if you posted the definition of the stored procedure if its 'small' enough

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

It's not clear how many values you're expecting - for a single value, ExecuteNonQuery will do
1) Im not sure you need to fanangle with the connection state as such
2) it doesnt look like you've defined an output parameter
3) manually closing a connection is so passe - using blocks should be applied instead .. so maybe
string i = "";
SQLHelper conn = new SQLHelper();
using (OracleConnection connection = new OracleConnection(conn.GetConnectionString(dbname)))
using (OracleCommand command = new OracleCommand("XYZ", connection))             
  command.CommandType = CommandType.StoredProcedure;
  command.Parameters.Add("val", OracleDbType.Varchar2, 120);
  command.Parameters["val"].Direction = ParameterDirection.Output;
  i = command.Parameters["val"].Value.ToString();
Developer29 10-Jul-20 11:31am
i have defined output parameter i missed out to mention here. I have two input parameter and one output parameter.
Developer29 10-Jul-20 11:33am
I added Connection state to verify the successful connection.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100