I'm not using DbDataTables, just OracleConnection, OracleCommand and OracleReader.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.
OracleException: Network error ???
-
- Posts: 9
- Joined: Wed 02 Apr 2008 03:14
-
- Posts: 729
- Joined: Thu 13 Dec 2007 10:24
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.
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.
-
- Posts: 23
- Joined: Fri 16 Nov 2007 20:10
- Location: Germany
Sample
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 .
Alex
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 .
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
-
- Posts: 23
- Joined: Fri 16 Nov 2007 20:10
- Location: Germany
-
- Posts: 729
- Joined: Thu 13 Dec 2007 10:24