locked
Error while connecting DB RRS feed

  • Question

  • User553394437 posted

    Hi,

    I've an issue with oracle DB connectivity and this issue is occuring occasionally.  Below i given the DB connectivity code and the issue i found in the log.  Can naybody look into this and give me a solutions.

    #region GetSourceData
            public DataSet GetSourceData(string connectionString, string query)
            {
                DataSet IsQueryProcessed = new DataSet();
                try
                {
                    logger.Info("Connecting to Oracle database ");
                    OracleConnection connect = new OracleConnection(connectionString);
                    try
                    {
                        logger.Info("Connect String " + connectionString);
                    }
                    catch (Exception generalExcepiton)
                    {
                        logger.Error("Error while writing connection string " + generalExcepiton.ToString());
                    }
    
                    connect.Open();
    
                    OracleCommand command = connect.CreateCommand();
                    command.CommandType = CommandType.Text;
                    command.CommandText = query;                
    
                    OracleDataAdapter getRecords = new OracleDataAdapter(command);
                    getRecords.Fill(IsQueryProcessed, "Chat");
                    logger.Debug("Retrieved records from data base Successfully");
                    
                    connect.Close();
                    logger.Debug("Closing the data base connection Successfully");
    
    
                }
                catch (Exception generalException)
                {
                    logger.Error("Error oc getting details from database " +
                        generalException.ToString());
                }
                return IsQueryProcessed;
            }
            #endregion
    Error From Log:
    2011-12-15 14:05:16,660 [5828] ERROR WebDataAcces Error oc getting details from database System.InvalidOperationException: CommandText property has not been initialized.
       at System.Data.OracleClient.OracleCommand.get_StatementText()
       at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciRowidDescriptor& rowidDescriptor, ArrayList& resultParameterOrdinals)
       at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, ArrayList& resultParameterOrdinals)
       at System.Data.OracleClient.OracleCommand.ExecuteReader(CommandBehavior behavior)
       at System.Data.OracleClient.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)
       at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
       at WebDataAcces.GetSourceData(String connectionString, String query) in d:\Websites\www\App_Code\WebDataAcces.cs:line 51
    2011-12-15 14:05:16,660 [5828] INFO  SimpleSamples801_MainChatPage GetOperationDetails table count is 0 
    
    
    The Error line 51 is highlighted with Bold letters.  Please let me know what is the issue.
    Thanks,
    Ram
    Sunday, December 18, 2011 9:08 PM

All replies

  • User-1666856491 posted

    Hi Ram_TPS

    Problem is with your query, check it out.

    Sunday, December 18, 2011 10:59 PM