Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

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.
Error:
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:

C#
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;
                con.Open();
                // cmd.ExecuteNonQuery();
                ConnectionState state = con.State;
                if (state == ConnectionState.Open)
                {
                     var j = cmd.ExecuteReader();
                    //cmd.ExecuteNonQuery();

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

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

<add name="smart04" connectionstring="Data Source=  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.150.5.46)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = smart04) 
    ));user id=xxxx;password=yyyy;" providername="System.Data.OracleClient">
Posted
Updated 10-Jul-20 1:49am
v5
Comments
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

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;
  connection.Open();
  command.ExecuteNonQuery();
  i = command.Parameters["val"].Value.ToString();
}
 
Share this answer
 
Comments
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900