I am testing a VB.NET application using SQL Server Express (2005) and
ADODB.
Multiple instances of the application all access the database. In some
cases, they access and try to update the same row of a table. I am
opening this table with a single row query and
ADODB.LockTypeEnum.adLockPessimistic which I understand to be
equivalent to ROWLOCK.
Sample query:
SELECT Semaphores.* FROM Semaphores WHERE
(((Semaphores.SemaphoreName)='MySem'));
PROBLEM:
This query should always return the one record where this condition is
true. Most of the time it does this. However, sometimes it opens
without error, but the EOF condition is true (even though the query
should return the existing record).
My assumption was that the adLockPessimistic would fail the Open with
an exception if the the row could not be accessed with the lock. Is it
possible I am instead getting an EOF in this case? If not, any ideas
what may cause an EOF on a query that works almost every other time?
Other settings:
m_Connection.CommandTimeout = 5
m_Connection.ConnectionTimeout = 15
SET LOCK_TIMEOUT 0
Note:
Since I know the record is there, I could technically loop on the
erroneous EOF to get around the problem. But I believe I am seeing it
occur in other places where I cannot guarantee the EOF is not valid.
Gary Geniesse"GaryGen" <gary@.garygen.com> wrote in message
news:1146582362.350598.240750@.j73g2000cwa.googlegroups.com...
>I am testing a VB.NET application using SQL Server Express (2005) and
> ADODB.
Why are you using ADODB instead of System.Data.SqlClient?
> Multiple instances of the application all access the database. In some
> cases, they access and try to update the same row of a table. I am
> opening this table with a single row query and
> ADODB.LockTypeEnum.adLockPessimistic which I understand to be
> equivalent to ROWLOCK.
>
Ditch ADODB, use SqlClient, and read the BOL for lock hints and OUTPUT
clause.
No one remembers details of exactly ADO works, and no one wants to figure it
out. But plenty of people here can help with pure SQL solutions.
So what are you trying to acomplish? What are the table structures (DDL
please), and desired results?
David
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment