Forum Discussion

sankar_k's avatar
sankar_k
Occasional Contributor
10 years ago
Solved

Checking success of DB transaction

Hi There



I am trying to insert a record into Microsoft SQL Server database table using ADO objects. The sample code is as follows



Dim AConnection 

  Set AConnection = ADO.CreateADOConnection

  AConnection.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=EASDS;UID=eas_system;PWD=EAS" 

  AConnection.LoginPrompt = False

  AConnection.Open

  AConnection.Execute_("Insert into emp('1','Sankar')



The code works properly. I want to know whether the last statement AConnection.Execute_ is successful or not. Appreciate if you some one can throw a light on this




 


  • If it is not successful, you'll get an exception and script execution will stop. Sp you will definitely know it was not successful :)

2 Replies

  • karkadil's avatar
    karkadil
    Valued Contributor
    If it is not successful, you'll get an exception and script execution will stop. Sp you will definitely know it was not successful :)
  • sankar_k's avatar
    sankar_k
    Occasional Contributor
    Thanks for the quick response.  I check the connection using the sytax



    If AConnection.Connected then

    -----



    Else

    Log.Error ("Connection Faile")

    End If



    Will I be able to do something similar in these lines