I have two computers, a Windows XP machine with MDAC 2.7 SP1 (sqlsrv32.dll
version 2000.81.9042.0) and a Windows Server 2003 machine with MDAC 2.8 SP2
for Server 2003 (sqlsrv32.dll version 2000.86.1830.0) as confirmed by MDAC
Component Checker.
They are both connecting to the same machine with SQL Server 2000 with SP4.
I am submitting the several SQL commands through .NET OleDb (Framework 1.1)
to a JET DB (Access 2003) with a linked table to SQL Server. I have also
connected to JET through ODBC in the past as well with the same results.
I am inserting a record into a linked table called "Events" with one
autonumbered IDENTITY column called EventKey.
I have started a transaction through the BeginTransaction .NET methods. I
submit the following SQL commands (.NET pseudo-code'ish):
ExecuteNonQuery("INSERT INTO Events (EventMember) VALUES (6)")
var key = ExecuteScalar("SELECT @@IDENTITY")
ExecuteQuery("SELECT * FROM Events WHERE EventKey = " & key)
The first two commands run successfully, but the third command fails with
the following error: "System.Data.OleDb.OleDbException: ODBC--call failed."
after about a minute timeout.
Upon checking SQL Enterprise Manager, there are two processes (one blocking,
one blocked). The blocking process last executed the "SELECT @@IDENTITY",
the blocked process executed the "select * from..." query. After a lock
timeout, the SELECT * query returns with that error.
My question is: why are TWO connections being made to SQL Server for the
same transaction? Since all three queries are coming from the same source
JET connection, of course that second connection to SQL server while the
first connection has that inserted record locked will fail to read it.
This works perfectly from MDAC 2.7, but fails every time with MDAC 2.8. I
have tried to go through the "List of bug fixes" KB articles, but nothing was
listed about a fix that I would think may break this idea other than
asynchronous fetching?
Any ideas - our application heavily uses this approach to insert new records
through ADO.NET and then select the records back during the same transaction.
Thanks,
Mike Dearman
Lead Software Engineer