AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Datenbanken Delphi ADODB Transaction and MSSQL

ADODB Transaction and MSSQL

Ein Thema von miroslaw · begonnen am 14. Jan 2007 · letzter Beitrag vom 15. Jan 2007
Antwort Antwort
miroslaw

Registriert seit: 14. Jan 2007
3 Beiträge
 
#1

ADODB Transaction and MSSQL

  Alt 14. Jan 2007, 23:21
Datenbank: MSSQL 2005 Express • Zugriff über: ADO
Hello,

I'd like to use transactions accessing MSSQL 2005. I'm using Delphi 5.
The following code causes Ole exception:

Delphi-Quellcode:
    _conId := TADOConnection.Create (nil);

    _conId.ConnectionString := ConnString;
    _conId.IsolationLevel := ilSerializable;
    _conId.LoginPrompt := False;
    _conId.CursorLocation := clUseClient;
    _conId.Mode := cmShareExclusive ;
    _conId.Open('mirek2', 'mirek2');

    _qrySelectCircle := TADOQuery.Create(nil);
    _qrySelectCircle.SQL.Text := 'SELECT VALUE FROM TAB WHERE NAME = :Name';
    with _qrySelectCircle.Parameters.AddParameter do
    begin
        Name := 'Name';
       DataType := ftString;
        Direction := pdInput;
    end;
    _qrySelectCircle.Prepared := True;
    _qrySelectCircle.Connection := _conId;

    _conId.BeginTrans();

   _qrySelectCircle.Parameters.ParamByName('Name').Value := circle;
   _qrySelectCircle.CursorType := ctKeyset   ;
   _qrySelectCircle.LockType := ltOptimistic;
   _qrySelectCircle.RecordSet := nil;
   _qrySelectCircle.Open();
At this point an exception occurs:

In German:
"Mehrfache Recordsets sind bei einer Transaktion mit diesem Cursortyp nich
t moeglich. Aendern Sie entweder den Cursortyp, fuehren Sie Commit fuer die Transakt
ion aus, oder schliessen Sie eines der Recordsets"

which translates into english
"multiple recordsets are not possible for a transaction with this cursor type. Change either the cursor type or execute commit or close one record set"

What am I doing wrong and how can I fix it. I really need the transactios.

Thanks in advance
  Mit Zitat antworten Zitat
Benutzerbild von MagicAndre1981
MagicAndre1981

Registriert seit: 4. Jun 2004
Ort: Nordhausen
2.214 Beiträge
 
Delphi 7 Enterprise
 
#2

Re: ADODB Transaction and MSSQL

  Alt 14. Jan 2007, 23:27
Hi, you could try

clUseServer . This should fix your issue.

Welcome to DelphiPraxis
André
"A programmer is just a tool which converts caffeine into code", daran wirds wohl liegen, dass ich Abends nie pennen kann

Zitat von Luckie:
Nicht nur dass ihr offtopic geworden seid, jetzt werdet ihr selber im Offtopic noch offtopic
  Mit Zitat antworten Zitat
miroslaw

Registriert seit: 14. Jan 2007
3 Beiträge
 
#3

Re: ADODB Transaction and MSSQL

  Alt 14. Jan 2007, 23:37
no this doesn't solve the problem.

The error disappears when I don't call BeginTrans but in that case I have autocomit which I definitely don't want.
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#4

Re: ADODB Transaction and MSSQL

  Alt 15. Jan 2007, 07:03
hi miroslaw,

its very strange that you have to use a transaction just 4 reading data.

cu

Oliver
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat
miroslaw

Registriert seit: 14. Jan 2007
3 Beiträge
 
#5

Re: ADODB Transaction and MSSQL

  Alt 15. Jan 2007, 19:31
Oliver,

nice to hear from you.

As you can see the code goes to the place where the error occurs.
In reality there are 25763¼ SQL statements which should be protected
by ACID, or simply speaking transaction.

Anyway I connot imagine that it should be forbidden to you transactions
for select statements also.

cu

Mirosalw
  Mit Zitat antworten Zitat
alzaimar
(Moderator)

Registriert seit: 6. Mai 2005
Ort: Berlin
4.956 Beiträge
 
Delphi 2007 Enterprise
 
#6

Re: ADODB Transaction and MSSQL

  Alt 15. Jan 2007, 20:20
Hi miroslav,

First, try to simplify your code, i.e. get rid of the parameter stuff. This makes it easier to trace the error. Remove as much lines as possible.

Then, do not clear the recordset (MyQuery.Recordset := nil). TADOQuery is a delphi (borland) wrapper for the ADO recordset object (or something like that) and takes care of all the underlying ADO/OLE stuff.

As my companions mentioned before, a select does not necessarily have to be protected by a transaction. Try to fiddle arround with the isolation level of the DML-statements to get the most rigid protection you need.

But first try to simplify your code.
"Wenn ist das Nunstruck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput!"
(Monty Python "Joke Warefare")
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:15 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz