Forum Discussion

DKNP's avatar
DKNP
Occasional Contributor
8 years ago

DBTable - Interacting with a DBTable if it is a passed parameter to a function\routine

Hi

 

I currently have a DB table variable which is a variable of a keyword test. The DBTable is pointing to a spreadsheet stored on the local computer.

 

The keyword test calls a function and I pass the DBtable variable as a parameter.

 

The DBTable object is visible and passed when I inspect it via the watch list as it shows the columncount.

 

My problems come when i try to interact with the passed variable as nothing i have tried appears to work.

 

Do you have any documentation or examples to show how to interact with the passed DB Table variable.

 

I want to iterate through all the columns and rows and extract the stores values.

  • tristaanogre's avatar
    tristaanogre
    8 years ago

    Just as a note, I tried it and it's working fine for me.  I have an Excel spreadsheet with two columns in it: Value1 and Value2.  I have that spreadsheet assigned to a DBTable variable on a keyword test.  I then pass that variable to the following function.  My log shows the values of each column for each row as I iterate through the rows from beginning to end.

     

    function testDBTable(myTable) {
    
        while (!myTable.IsEOF()) {
            Log.Message('Column 1 data: ' + myTable.Value('Value1'));
            Log.Message('Column 2 data: ' + myTable.Value('Value2'));
            myTable.Next();
        }
    }
  • DKNP's avatar
    DKNP
    8 years ago

    Thanks, that works.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Can you post what you've done to date?  That would be helpful in determining, perhaps, why it's not working and give a better proposed solution.

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      Just as a note, I tried it and it's working fine for me.  I have an Excel spreadsheet with two columns in it: Value1 and Value2.  I have that spreadsheet assigned to a DBTable variable on a keyword test.  I then pass that variable to the following function.  My log shows the values of each column for each row as I iterate through the rows from beginning to end.

       

      function testDBTable(myTable) {
      
          while (!myTable.IsEOF()) {
              Log.Message('Column 1 data: ' + myTable.Value('Value1'));
              Log.Message('Column 2 data: ' + myTable.Value('Value2'));
              myTable.Next();
          }
      }
      • DKNP's avatar
        DKNP
        Occasional Contributor

        Thanks, that works.