Re: 0x800a0cb3 when Update record
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Thu, 16 Oct 2008 13:00:50 -0400
Anders Eriksson wrote:
What is the error description? DifferentThe error message is:
providers may have different error messages for the same error code.
It's blank?
What does the sql variable contain?The sql variable contains this:
sql.Format(_T("SELECT
ST.OrderNr,ST.Version,ST.Verkstad,ST.Laser,ST.Producerad,ST.Prioritet
") _T("FROM Orders ST ")
_T("INNER JOIN ")
_T("(SELECT OrderNr,MAX(Version) AS Version ")
_T("FROM Orders GROUP BY OrderNr) ST2 ON ST.OrderNr = ST2.OrderNr AND
ST.Version = ST2.Version ")
_T("WHERE (ST.Laser=%d OR ST.Laser=0 OR ST.Laser IS NULL) AND((NOT
(ST.Producerad=-1)) OR (ST.Producerad IS NULL)) AND (Stoppad=0) AND
(ST.FelKod=0) AND(NOT (ST.Verkstad='MAN')) ")
_T("ORDER BY ST.Prioritet DESC,ST.Tid,ST.OrderIndex"),m_laserId);
:-)
I did not ask how you defined the variable: I asked what it _contained_. Two
different things. Again, I don't do C++ but what I was asking for was the
result of
Write(sql)
or however you would do that in C++.
Well, your recordset is based on a join which may or may not make it
updatable. The fact that it is successful with a client-side static cursor
leads me to believe that the join has nothing to do with your problem
Why are you using adCmdUnknown instead of adCmdText?Just a misstake, I have changed it in my code
You should test the LockType and CursorType properties after opening
the recordset to verify that the provider was able to give you the
types you requested.
I have done that now, CursorType=adOpenForwardOnly and
LockType=adReadOnly. So it has not changed from the default values.
That means you have asked for incompatible settings. I really see nothing
that should lead to that incompatability. Where's Bill Vaughn when you need
him?
Maybe the join is the problem after all ... I'm just guessing here. You may
want to play with the "Unique Table" dynamic property of the recordset
object. I've never had to use it myself (preferring to use DML for data
modifications rather than recordsets) but there is documentation for it.
Do I need any specific rights in the database to be able to lock it?
No. The database handles locking.
Are you sure you need adLockPessimistic? Most experts advise againstI think I need it ;-) In the database is a queue of orders, I have
using that lock type except in extreme circumstances. In this case
you are using an explicit transaction, so that lock type is probably
not needed at all.
multiple programs that work the queue and each program will take the
first record that has not been work on, flag it as working and then
continue working until the record is done. I have tried this with an
Optimistic locking but then I got the same record working in multiple
programs.
As to ADO transactions not working with client-side cursors, IAha, You need to read the header also ;-)
believe the only case where this is true is with RDS, which you are
not using.
Why?
However, as Ralph mentioned, you would probably be better off usingI don't get how to create an sql statement that performs an UPDATE as
an UPDATE sql statement to perform this update rather than a
recordset.
well as returning a couple of column values within a transaction...
That's a job for a stored procedure with some output parameters.
Seriously, let SQL Server take care of your transactions for you: create a
stored procedure that accepts some input values, does all the processing in
the database, and returns the output values to your application. Instead of
output values, you could have it return a resultset if multiple rows of
output data are needed.
Well, unfortunately I may not be able to provide one.
For this project I can live with a client cursor, but since I forsee
that I'm going to need to be able to update a record using server
cursor I would appreciate an answer...
--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
.
- Follow-Ups:
- Re: 0x800a0cb3 when Update record
- From: Anders Eriksson
- Re: 0x800a0cb3 when Update record
- From: Ralph
- Re: 0x800a0cb3 when Update record
- References:
- 0x800a0cb3 when Update record
- From: Anders Eriksson
- Re: 0x800a0cb3 when Update record
- From: Ralph
- Re: 0x800a0cb3 when Update record
- From: Anders Eriksson
- Re: 0x800a0cb3 when Update record
- From: Anders Eriksson
- Re: 0x800a0cb3 when Update record
- From: Bob Barrows [MVP]
- Re: 0x800a0cb3 when Update record
- From: Anders Eriksson
- Re: 0x800a0cb3 when Update record
- From: Bob Barrows [MVP]
- Re: 0x800a0cb3 when Update record
- From: Anders Eriksson
- 0x800a0cb3 when Update record
- Prev by Date: Re: 0x800a0cb3 when Update record
- Next by Date: Re: 0x800a0cb3 when Update record
- Previous by thread: Re: 0x800a0cb3 when Update record
- Next by thread: Re: 0x800a0cb3 when Update record
- Index(es):
Relevant Pages
|
Loading