D
Dom
I have a program in which the Form1_Load event does a lot of database
work. Meanwhile, the user looks at a blank screen when he could be
doing other work while the DB stuff is getting done. So I thread out
the DB work. The Thread is sent a Form1 method as a "Callback". And
when the thread is finished, it invokes the Callback, and passes the
DB information. This has always worked when the DB was SQL Server,
and I used the SqlDataReader class. But now, I have to use the Oracle
server, and the OleDbDataReader class, and it fails. I've recreated
the problem in a paired down program. Am I doing something wrong, or
have I found a bug in the OleDbDataReader class?
Here is Form1.cs
---------------------------------------------------------------------------------
using System;
using System.Data.OleDb;
using System.Windows.Forms;
using System.Threading;
namespace OleDB_Thread
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Builder b = new Builder();
Thread t = new Thread(b.Fill);
t.Start((Builder.CallbackDelegate)Form1_Callback);
}
private void Form1_Callback(OleDbDataReader r)
{
[ Use "r"]
}
}
}
Here is Builder.cs which is called in a Thread
----------------------------------------------------------------
using System;
using System.Data.OleDb;
using System.Windows.Forms;
namespace OleDB_Thread
{
class Builder
{
public delegate void CallbackDelegate(OleDbDataReader r);
public void Fill(object o)
{
OleDbConnection c = new
OleDbConnection([ConnectionString]);
c.Open();
OleDbCommand m = new OleDbCommand([SQL Statement], c);
OleDbDataReader r = m.ExecuteReader();
CallbackDelegate Callback = (CallbackDelegate)o;
((Form)Callback.Target).Invoke(Callback, r);
}
}
}
-------------------------------------------------------------------------------------------------------------------
The program fails where I have written [Use "r"]. I get the message:
"Unable to cast COM object of type 'System.__ComObject' to interface
type 'IRowset'. This operation failed because the QueryInterface call
on the COM component for the interface with IID '{0C733A7C-2A1C-11CE-
ADE5-00AA0044773D}' failed due to the following error: No such
interface supported"
Keep in mind that if I use SQL Server, and make the relevant changes
in the code, it works fine.
Any ideas?
work. Meanwhile, the user looks at a blank screen when he could be
doing other work while the DB stuff is getting done. So I thread out
the DB work. The Thread is sent a Form1 method as a "Callback". And
when the thread is finished, it invokes the Callback, and passes the
DB information. This has always worked when the DB was SQL Server,
and I used the SqlDataReader class. But now, I have to use the Oracle
server, and the OleDbDataReader class, and it fails. I've recreated
the problem in a paired down program. Am I doing something wrong, or
have I found a bug in the OleDbDataReader class?
Here is Form1.cs
---------------------------------------------------------------------------------
using System;
using System.Data.OleDb;
using System.Windows.Forms;
using System.Threading;
namespace OleDB_Thread
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Builder b = new Builder();
Thread t = new Thread(b.Fill);
t.Start((Builder.CallbackDelegate)Form1_Callback);
}
private void Form1_Callback(OleDbDataReader r)
{
[ Use "r"]
}
}
}
Here is Builder.cs which is called in a Thread
----------------------------------------------------------------
using System;
using System.Data.OleDb;
using System.Windows.Forms;
namespace OleDB_Thread
{
class Builder
{
public delegate void CallbackDelegate(OleDbDataReader r);
public void Fill(object o)
{
OleDbConnection c = new
OleDbConnection([ConnectionString]);
c.Open();
OleDbCommand m = new OleDbCommand([SQL Statement], c);
OleDbDataReader r = m.ExecuteReader();
CallbackDelegate Callback = (CallbackDelegate)o;
((Form)Callback.Target).Invoke(Callback, r);
}
}
}
-------------------------------------------------------------------------------------------------------------------
The program fails where I have written [Use "r"]. I get the message:
"Unable to cast COM object of type 'System.__ComObject' to interface
type 'IRowset'. This operation failed because the QueryInterface call
on the COM component for the interface with IID '{0C733A7C-2A1C-11CE-
ADE5-00AA0044773D}' failed due to the following error: No such
interface supported"
Keep in mind that if I use SQL Server, and make the relevant changes
in the code, it works fine.
Any ideas?