Re: 0x800a0cb3 when Update record



Anders Eriksson wrote:
What is the error description? Different
providers may have different error messages for the same error code.
The error message is:

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 against
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.

I think I need it ;-) In the database is a queue of orders, I have
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, I
believe the only case where this is true is with RDS, which you are
not using.

Aha, You need to read the header also ;-)

Why?


However, as Ralph mentioned, you would probably be better off using
an UPDATE sql statement to perform this update rather than a
recordset.
I don't get how to create an sql statement that performs an UPDATE as
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.


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...

Well, unfortunately I may not be able to provide one.

--
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"


.



Relevant Pages

  • Re: Gebundene Controls aus ADO-Recordset aktualisieren
    ... Engpass ist vor allem das LAN und der Server selbst. ... ob man mit einem SQL-Server oder der Jet-Engine ... Cursor und statischen Recordsets, egal welches Datenbanksystem ... dass eine Bewegung im Recordset eben auch ...
    (microsoft.public.de.vb.datenbank)
  • Re: Gebundene Controls aus ADO-Recordset aktualisieren
    ... Wozu ein serverseitiger Cursor? ... Ich kann also z.B. bei adOpenKeyset im Programmcode ... CursorLocation adUseServer bei Access sinnlos, ... wenn Du in Deinem Recordset zu einem anderen ...
    (microsoft.public.de.vb.datenbank)
  • Re: Suche mit SEEK
    ... ein Recordset mit serverseitigem Cursor ... Das heisst also es muss ein Recordset mit serverseitigem Cursor ... clientseitigem Cursor arbeiten und die Suche nach einem bestimmten Datensatz ...
    (microsoft.public.de.vb.datenbank)
  • Re: How to summarize recordset...Select Distinct alternative?
    ... functionality to store a set of paired values ... then the recordset is copied into local ... ADO provides a Cursor Library that provides the cursor ... reconnected to the database simply by setting the ActiveConnection to an ...
    (microsoft.public.data.ado)
  • Re: CursorType, LockType von ADO-Recordsets
    ... Use the CursorType property to specify the type of cursor that should be used when opening the Recordset object. ... If an unsupported value is set, then no error will result; the closest supported CursorType will be used instead. ...
    (microsoft.public.de.access.clientserver)

Loading