Bugs
Search the entire project
This project's trackers
This project's forums
This project's tasks
This project's releases
This project's documents
This project's news
Project
People
Skill
Advanced search
Log In
|
New Account
Home
My Page
Projects
Code Snippets
Project Openings
PostgreSQL OLE DB provider for Windows
Summary
Activity
Forums
Tracker
Lists
Tasks
Docs
Surveys
News
SCM
Files
[#1000338] Bug using C# OLEDB connection and threads
View Trackers
|
Bugs
|
Download .csv
|
Monitor
Date:
2005-06-21 16:43
Priority:
3
State:
Open
Submitted by:
Jean-Philippe JACOUPY (
zeth
)
Assigned to:
Nobody (None)
Category:
Crash
Group:
v1.0.0.19
Resolution:
None
Summary:
Bug using C# OLEDB connection and threads
Detailed description
Here's my problem.
I'm running a PostgreSQL v8.0 with PgOleDb v1.0.0.19 under Windows. I want to connect to it in a thread using C# OleDB connection. I can create my connection but whenever I try to execute a simple query "SELECT MAX(id) FROM table;"
When I run the data reader, I obtain an exception as follow: E_NOINTERFACE.
The problem only occur in a Thread and only with a SELECT query (with an insert it works).
When I run the query in the main thread, and not in it's own thread, it works.
My connection string:
"Provider=PostgreSQL;Data Source=localhost;location=EXOS;User ID=nyu;password=nyu"
Here is my sample code I use to execute my query:
System.Data.OleDb.OleDbDataReader aReader;
[...]
aReader = myCommand.ExecuteReader();
while(aReader.Read() )
{
sWork = aReader.GetInt32(0).ToString();
Console.WriteLine(sWork);
}
aReader.Close();
I have attached the traces (level 3 trace log) of PgOleDb of the problem in a thread.
- Exception from .NET:
'System.Data.OleDb.OleDbException': E_NOINTERFACE(0x80004002).
- Stack Trace:
system.data.dll!System.Data.OleDb.OleDbDataReader::ProcessResults(__int32 hr = -2147467262) + 0x5a octets
system.data.dll!System.Data.OleDb.OleDbDataReader::NextResult() + 0x131 octets
system.data.dll!System.Data.OleDb.OleDbCommand::ExecuteReaderInternal(System.Data.CommandBehavior behavior = Default, String* method = "ExecuteReader") + 0x14c octets
system.data.dll!System.Data.OleDb.OleDbCommand::ExecuteReader(System.Data.CommandBehavior behavior = Default) + 0x35 octets
system.data.dll!System.Data.OleDb.OleDbCommand::ExecuteReader() + 0x12 octets
Followup
Message
Date: 2012-03-07 17:17
Sender:
tomi crow
you can see in different ways to connect database from following link
http://csharp.net-informations.com/data-providers/csharp-dataproviders-tutorial.htm
crow
Date: 2006-04-29 11:59
Sender:
Sławomir Wojtasiak
ODBC works fine, but I had some problems using it with C# (version 8.0.1.1). This version sometimes creshed without concrete reason. One of my friends told me that it has been fixed in new versions of driver, but I didn't test them. In future I plan to use Npgsql - .Net Data Provider.
Date: 2005-12-01 13:03
Sender:
Jean-Philippe JACOUPY
Well It is a bit more complicated since I'm in a real time
environnement I can't use dynamic connections.
I've found a work around with static connection but I had to
pass my connection instance to any function whitch needed
the connection (even if she is static). This was kinda odd,
so I went with the ODBC drivers.
I need to try one last thing for OleDB drivers Ill post back
the results.
--
Regards,
JACOUPY Jean-Philippe
Date: 2005-09-17 20:59
Sender:
Sławomir Wojtasiak
The error that you describe in your first post, you can resolve by adding Application.OleRequired() in your thread. I didn't try static connections, but when I use dynamic all work fine with select-like query and any other. Maybe problem is due to open connection by other thread.
[...]
/// <summary>
/// New therad.
/// </summary>
public void GeneratorThread() {
Application.OleRequired();
IDbConnection connection = m_DatabaseCtrl.Connection;
IDataReader reader = null;
try {
connection.Open();
IDbCommand command = connection.CreateCommand();
String query = String.Format("SELECT MAX(\"Value\") FROM \"Table\"");
command.CommandText = query;
reader = command.ExecuteReader(CommandBehavior.SingleRow);
if(reader.Read()) {
int val = reader.GetInt32(0);
[...]
This code work without any arrors. And now, when I remove the line with Application.OleRequired();, I will get the same error as you.
Date: 2005-09-14 09:03
Sender:
Jean-Philippe JACOUPY
I tryed, it kinda worked for part of the thread, then by the
end, it crashed.
When I do the "SELECT MAX(ID) FROM Table;" I still get the
error right before "the Reader = CdeDB.ExecuteReader();"
statement. I tryed to use "CdeDB.ExecuteScalar();" method
but it sends the same Exception. I've also tryed to add
again Application.OleRequired(); but it has no effect at
that point. This part is in a function which uses a static
connection.
When I use ODBC components instead of OleDb, it works just
fine.
Date: 2005-09-12 16:53
Sender:
Sławomir Wojtasiak
Try to use Application.OleRequired() in your new thread.
Date: 2005-08-16 20:09
Sender: Nobody
I am getting the same behavior. Has there been any work to fix this issue? It is a show stopper!
Attached Files:
Attachments:
PostgreSQLOleDB - own thread.log
Changes:
Field
Old Value
Date
By
assigned_to
shachar
2005-12-01 12:55
shachar
File Added
48: PostgreSQLOleDB - own thread.log
2005-06-21 16:43
zeth