Ask a Question

JScript to JavaScript conversion and adoDB delete

SOLVED
S_Seydel
Contributor

JScript to JavaScript conversion and adoDB delete

Greetings,

 

I currently work on converting the language of my scripts from JScript to JavaScript. So far Smartbear's documentations on this topic JavaScript for JScript Users and Converting Scripts From One Scripting Language To Another were very helpful.

However at this point I face a problem I was not able to find a solution for so far.

To delete tupils from a database I use the following funtion:

 

  /* 
   *  Delete tupels from a database table
   *  Value parameter can be datatype object with value null
   *
   *  @param table = mandatory; string; the database table to search;
   *  @param column = mandatory; string; the database table's column to search;
   *  @param value = mandatory; string; the value to search for in the database table's column;
   */   
  function adoDelete(table, column, value)
  {
    //  Open the database connection
    var connection = openDatabaseConnection();
    //  Open the recordset we need
    var recordset = openRecordset(connection, table);

    //  Iterate through the recordset and delete all appropriate tupels    
    recordset.MoveFirst;
    
    while(equal(recordset.EOF, false))
    {
      if (equal(recordset.Fields.Item(column).Value, value))
      {
        recordset.Delete;
      }
      recordset.MoveNext;
    }
  }

Using JScript this function ran fine for the last two years.

Using JavaScript all code lines are executed without producing an error message, but the tupil in the database is not deleted. Therefore the function runs for an infinite time, or until it is manually interrupted.

 

From debugging I know that the correct tupel was found when the if -block is executed.

 

Perhaps a kind community member has an idea, why the behaviour differs and how a solution could look like?

 

Thank you in advance

Sönke

1 ACCEPTED SOLUTION

Accepted Solutions
shankar_r
Community Hero

Re: JScript to JavaScript conversion and adoDB delete

Try this code, this may look crazy but worth a try

function adoDelete(table, column, value)
  {
    //  Open the database connection
    var connection = openDatabaseConnection();
    //  Open the recordset we need
    var recordset = openRecordset(connection, table);

    //  Iterate through the recordset and delete all appropriate tupels    
    recordset.MoveFirst();
    
    while(equal(recordset.EOF, false))
    {
      if (equal(recordset.Fields.Item(column).Value, value))
      {
        recordset.Delete();
      }
      recordset.MoveNext();
    }
  

Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

View solution in original post

2 REPLIES 2
shankar_r
Community Hero

Re: JScript to JavaScript conversion and adoDB delete

Try this code, this may look crazy but worth a try

function adoDelete(table, column, value)
  {
    //  Open the database connection
    var connection = openDatabaseConnection();
    //  Open the recordset we need
    var recordset = openRecordset(connection, table);

    //  Iterate through the recordset and delete all appropriate tupels    
    recordset.MoveFirst();
    
    while(equal(recordset.EOF, false))
    {
      if (equal(recordset.Fields.Item(column).Value, value))
      {
        recordset.Delete();
      }
      recordset.MoveNext();
    }
  

Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

View solution in original post

S_Seydel
Contributor

Re: JScript to JavaScript conversion and adoDB delete

That did it.

Thank you very much for the very fast reply.

cancel
Showing results for 
Search instead for 
Did you mean: