Forum Discussion

jose_pita's avatar
jose_pita
Super Contributor
12 years ago

Get feedback from ConnDB.Execute

Hi There,



Does anyone know how can I obtain feedback from an executed SqlQuery?

For example, I want to do an update on a DB Table and I want to know how many rows were affected, is this possible?



Here is the code I use:




function sqlQueryExecute(server, query)


{


  var ConnectionString = "DRIVER=SQL Server;SERVER="+ server +";UID=****;PWD=****";


  // Creates a new connection


  var ConnDB = ADO.CreateConnection();


  ConnDB.ConnectionString = ConnectionString;


  ConnDB.Open();


  


  ConnDB.Execute(query);


  Log.Message("QUERY EXECUTED")


  // Closes the connection  


  ConnDB.Close();


  


}

1 Reply

  • sbkeenan's avatar
    sbkeenan
    Frequent Contributor
    Hi Jose



    I don't know if the functionality you are looking for exists directly, although it would be nice!!



    However, a possible workaround might be to run a SELECT query first, this would allow you to obtain a count of the number of records returned.  This should be the same as the number of rows affected with the UPDATE query providing the WHERE clause is the same in both.



    Regards

    Stephen.