Re: ADO and DELETE Statement



Hi,

Sorry, I don't understand the Navision code. Besides the BeginTrans,
CommitTrans, and RollbackTrans methods of the ADO connection object, SQL
itself has statements BEGIN, COMMIT, and ROLLBACK (Microsoft Access and
Microsoft SQL Server use BEGIN TRANSACTION). If you can submit more than one
SQL statement at a time (perhaps separated by semicolons), you can enclose
the relevant operations in a BEGIN / COMMIT block. You may not be able to
detect the failure, but if one occurs the purchase order is never posted.

I would expect documentation for Navision to discuss transactions.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

"Skeeve" <nospam@xxxxxxxxxxxxxxxxxx> wrote in message
news:m56j82h7of50ajh7cjfl12stcb2lllo6n8@xxxxxxxxxx
On Thu, 8 Jun 2006 19:08:28 -0500, "Richard Mueller"
<rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx> wrote:

Hi,

Can you use transactions? The ADO connection object has BeginTrans,
CommitTrans, and RollbackTrans methods. Also, if an error is raised when
the
delete fails, you should be able to trap that. In brief:

read record
BeginTrans
post purchase order
delete record
CommitTrans

If the CommitTrans method is never invoked because the delete failed, the
purchase order is never posted. Transaction rollbacks apply to INSERT,
UPDATE, and DELETE statements, but not SELECT, CREATE, ALTER, or DROP.

Well, I am doing this in Navision (Dynamics-NAV) using the MS ActiveX
Data Access lib. I have looked at all kinds of properties on the
connection object, nothing indicated an error status (same values,
regardless of success or failure).

To give you an idea of what I am doing, here is the relevant code
snippet:


sSql := '';
sSql := 'DELETE FROM Test_Warehouse_Transfer WHERE PO_No = ' +
'''' + 'P00000983' + '''';
SQL_Execute_Delete(sSql);

And then the function:

SQL_Execute_Delete(pInSQL : Text[1024])
IF ISCLEAR(adoRS2) THEN
CREATE(adoRS2);

adoRS2 := adoConnection.Execute(pInSQL);

temp1 := adoConnection.State;
//temp2 := adoRS2.RecordCount;

So the recordset is bascially empty because the DELETE operation
doesn't return a recordset.

The purchase order is posted in Navision. THat means that even if I
use the BeginTrans and CommitTrans in ADO and it fails, the PO is
still posted in Navision. It looks like this:

The first line is what posts the PO line in Navision. So if that
succeeds (TRUE is returned), I need to make 100% sure that the record
is deleted in SQL.

IF NOT lCuPostPO.RUN(lRecPO) THEN BEGIN
ERROR('Could not successfully post PO %1',lRecPO."No.");
END
ELSE BEGIN
// delete record from SQL
sSql := '';
sSql := 'DELETE FROM '+ gRecInventorySetup."Receiving
Confirmation" + ' WHERE CO = ' + '''' + COMPANYNAME() + '''';
sSql += ' AND Tag_No = ' + '''' + lTagNo + ''''; // The TAG
number from the receiving system is unique
SQL_Execute_Delete(sSql);
END;

Thanks for your help!


.



Relevant Pages

  • Re: ADO and DELETE Statement
    ... CommitTrans, and RollbackTrans methods. ... delete fails, you should be able to trap that. ... I am doing this in Navision using the MS ActiveX ...
    (microsoft.public.data.ado)
  • Problem importing data in SQL (DTS - ODBC - Navision Attain)
    ... I have a problem with importing data in SQL. ... I'm using DTS and ODBC to connect to Navision db. ... Microsoft OLE DB Provider for ODBC Drivers ...
    (microsoft.public.sqlserver.odbc)
  • SQL Merge Replication with Navision Client
    ... I am setting up SQL 2000 Enterprise Edition SP3, using The MS Navision ... Client 3.70a as the end user client software. ... I can get replication to succeed but on 3 tables I ...
    (microsoft.public.sqlserver.replication)
  • Converting Characters
    ... Currently I'm using MS-Navision with SQL 2005. ... Navision, when I do select statements in the SQL Server Management Studio, ... those double-byte characters in the correct format. ...
    (microsoft.public.dotnet.languages.csharp)
  • "Messaging Engine failed to retrieve the configuration from the database" error
    ... I keep receiving this error in the Event Viewer (I'm testing the Navision ... Commerce Gateway system) despite all the permissions (SQL etc.) looking OK ...
    (microsoft.public.biztalk.general)