OracleException: Network error ???

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
DwightFowler
Posts: 9
Joined: Wed 02 Apr 2008 03:14

Post by DwightFowler » Wed 02 Apr 2008 18:34

Alexey.mdr wrote:You may try this option, but it is still risky.
Several methods of DbDataTable won't work with resource blockers.
It is recommended to use as many connections as many threads exist.
I'm not using DbDataTables, just OracleConnection, OracleCommand and OracleReader.

Alexey.mdr
Posts: 729
Joined: Thu 13 Dec 2007 10:24

Post by Alexey.mdr » Thu 03 Apr 2008 15:29

What version of OraDirect .NET do you use?
We have fixed bug with disposing OracleDataReader in proxy connections in 4.50.31 19-Mar-08

You have mentioned some sample.
Could you please send it to me (alexeyman*crlab*com)?
OraDirect .NET supports multithreading, though it does not guaranty thread safety.

sprinter252
Posts: 23
Joined: Fri 16 Nov 2007 20:10
Location: Germany

Sample

Post by sprinter252 » Tue 08 Apr 2008 12:37

Hi,

I'll show you an example for producing "Network error 204" repeadetly. If I remove the line "System.Threading.Thread.Sleep(100);" the error occurs in ExecuteProcedure() on "ExecuteNonQuery". In some cases it will come to the exception-handler in most cases nothing happens and the app is frozen. In debugging mode I can see, that "ExecuteProcedure" is executed in main thread (VS 2008).

Sorry but I had to mix up some code from my libs together :D.

Code: Select all

        private void frmBase_Shown(object sender, EventArgs e)
        {            
            if (!DesignMode)
            {                
                LoadForm();
            }         
        }

        private void LoadForm()
        {
            if (!this.IsMdiChild)
            {
                // restore mode, size and position if the form is not a part of the MDI container                
                string strFormName = this.GetType().Name;
                IDatabase dbsThis = Tools.GetDefaultDatabase();                
                DbParameter parEmp = dbsThis.GenerateParameter("EMPLOYEE_ID_IN", 
                                                               DbType.Int32, 
                                                               Tools.CurrentEmployee.ID, 
                                                               ParameterDirection.Input);
                DbParameter parForm = dbsThis.GenerateParameter("FORM_NAME_IN", 
                                                                DbType.String, 
                                                                strFormName, 
                                                                ParameterDirection.Input);
                DbParameter parCtl = dbsThis.GenerateParameter("CONTROL_NAME_IN", 
                                                               DbType.String, 
                                                               strFormName, 
                                                               ParameterDirection.Input);
                DbParameter parSet = dbsThis.GenerateLOBParameter("SETTINGS_OUT", 
                                                                  string.Empty, 
                                                                  ParameterDirection.Output);
                System.Threading.Thread.Sleep(100);
                if (dbsThis.ExecuteProcedure("SP_GET_EMPLOYEE_FORM_SETTINGS", parEmp, parForm, parCtl, parSet))
                {
                    // the procedure was executed well
                    if (parSet.Value != null &&
                        parSet.Value.ToString().Length > 0)
                    {
                        // the result was written
                        string[] astrThis = parSet.Value.ToString().Split(';');
                        if (astrThis.Length == 5)
                        {
                            ControlHelper cthThis = new ControlHelper();
                            try
                            {
                                Point poiTmp = new Point(int.Parse(astrThis[2]), int.Parse(astrThis[1]));
                                Size sizTmp = new Size(int.Parse(astrThis[3]), int.Parse(astrThis[4]));
                                FormWindowState fwsThis = (FormWindowState)Enum.Parse(typeof(FormWindowState), astrThis[0]);
                                cthThis.ThreadSetFormState(this, fwsThis);
                                cthThis.ThreadSetControlLocation(this, poiTmp);
                                cthThis.ThreadSetControlSize(this, sizTmp);
                            }
                            catch
                            { }
                        }
                    }
                }
            }
            LoadControls(this);
            AfterFormRestore();
        }

        public DbParameter GenerateParameter(string strParameterName,
                                             DbType typParameterType,
                                             object objParameterValue,
                                             ParameterDirection pdirParameterDirection)
        {
            OracleParameter parReturn = null;
           
            //OracleDbType otypThis = MapOracleType(typParameterType, false);
            parReturn = new OracleParameter();
            parReturn.ParameterName = strParameterName;
            parReturn.DbType = typParameterType;
            if (objParameterValue is bool)
                objParameterValue = (bool)objParameterValue ? 1 : 0;
            parReturn.Value = objParameterValue;
            parReturn.Direction = pdirParameterDirection;

            return parReturn;
        }

        public DbParameter GenerateLOBParameter(string strParameterName,
                                                object objParameterValue,
                                                ParameterDirection pdirParameterDirection)
        {
            OracleParameter parReturn = null;
            
            parReturn = new OracleParameter();
                        
            parReturn.ParameterName = strParameterName;
            parReturn.OracleDbType = OracleDbType.Clob;
            if (objParameterValue is bool)
                objParameterValue = (bool)objParameterValue ? 1 : 0;
            parReturn.Value = objParameterValue;
            parReturn.Direction = pdirParameterDirection;

            return parReturn;
        }

        public bool ExecuteProcedure(string strProcedureName,                                     
                                     params DbParameter[] aparParams)
        {
            OracleCommand cmdThis;
            bool blnReturn = false;

            strProcedureName = AddSQLSchemaToObject(strProcedureName, false);

            // we will use a oracle stored procedure                
            cmdThis = new OracleCommand(strProcedureName, (OracleConnection)m_cinfThis.Connection);
            // parameters of the stored procedure should be bound by their name                        
            cmdThis.ParameterCheck = CheckProcedureParameters;
            foreach (OracleParameter oparThis in aparParams)
            {
                // cycle through all passed parameters and add them to the command
                cmdThis.Parameters.Add(oparThis);
            }
            // set some common properties
            cmdThis.CommandType = CommandType.StoredProcedure;
            cmdThis.CommandTimeout = 15;
            // start execution
            try
            {
                cmdThis.ExecuteNonQuery();
                blnReturn = true;
            }
            catch (Exception ex)
            {
                // store exception
                m_excLast = ex;
            }

            return blnReturn;
        }


Alex

sprinter252
Posts: 23
Joined: Fri 16 Nov 2007 20:10
Location: Germany

Post by sprinter252 » Tue 08 Apr 2008 13:02

Wow, I updated to CoreLab.Oracle 4.50.32.0 and the error disappears at this point!

Alex

Alexey.mdr
Posts: 729
Joined: Thu 13 Dec 2007 10:24

Post by Alexey.mdr » Tue 08 Apr 2008 13:17

That's great!
It's likely because of the fixed bug with OracleDataReader.

Post Reply