RowCount Property

Applies to TestComplete 15.44, last modified on November 10, 2022

Description

Use the DBTable.RowCount property to obtain the number of data rows stored by the DBTable project element that corresponds to the DBTable object. You can then use this value to iterate through stored values.

Declaration

DBTableObj.RowCount

Read-Only Property Integer
DBTableObj An expression, variable or parameter that specifies a reference to a DBTable object

Applies To

The property is applied to the following object:

Property Value

An integer value that specifies the number of stored rows.

Example

The code below obtains a database table element, determines the number of columns and rows it contains and then posts the table’s values row by row to the test log.

JavaScript, JScript

function DBTableExample()
{
  // Specifies a DB Table element
  var DBTab = DBTables.Table1;
  // Obtains the total number of rows
  // and columns of the table
  var RowNum = DBTab.RowCount;
  var ColNum = DBTab.ColumnCount;

  Log.Message("Number of rows:" + RowNum);
  Log.Message("Number of columns:" + ColNum);

  for (var i = 0; i < RowNum; i++)
  {
    var TableRow = "";
    for (var j = 0; j < ColNum; j ++)
    {
      // Specifies the current value
      var Val = DBTab.Values(i, j);
      // Forms the current row
      TableRow = TableRow + " " + VarToStr(Val);
    }
    // Posts the current row to the test log
    Log.Message(TableRow);
  }

}

Python

def DBTableExample():
  # Specifies a DB Table element
  DBTab = DBTables.Table1
  # Obtains the total number of rows
  # and columns of the table
  RowNum = DBTab.RowCount
  ColNum = DBTab.ColumnCount
  Log.Message("Number of rows:" + str(RowNum))
  Log.Message("Number of columns:" + str(ColNum))
  for i in range(0, RowNum):
    TableRow = ""
    for j in range(0, ColNum):
      # Specifies the current value
      Val = DBTab.Values[i, j]
      # Forms the current row
      TableRow = TableRow + " " + VarToStr(Val)
    # Posts the current row to the test log
    Log.Message(TableRow)

VBScript

Sub DBTableExample

  ' Specifies a DB Table element
  Set DBTab = DBTables.Table1
  ' Obtains the total number of rows
  ' and columns of the table
  RowNum = DBTab.RowCount
  ColNum = DBTab.ColumnCount

  Log.Message("Number of rows:" & RowNum)
  Log.Message("Number of columns:" & ColNum)

  For i = 0 to (RowNum - 1)
    TableRow = ""
    For j = 0 to (ColNum - 1)
      ' Specifies the current value
      Val = DBTab.Values(i, j)
      ' Forms the current row
      TableRow = TableRow & " " & VarToStr(Val)
    Next
    ' Posts the current row to the test log
    Log.Message(TableRow)
  Next

End Sub

DelphiScript

function DBTableExample;
var DBTab, RowNum, ColNum, i, j, TableRow, Val;
begin

  // Specifies a DB Table element
  DBTab := DBTables.Table1;
  // Obtains the total number of rows
  // and columns of the table
  RowNum := DBTab.RowCount;
  ColNum := DBTab.ColumnCount;

  Log.Message('Number of rows:' + IntToStr(RowNum));
  Log.Message('Number of columns:' + IntToStr(ColNum));

  for i := 0 to (RowNum - 1) do
  begin
    TableRow := '';
    for j := 0 to (ColNum - 1) do
    begin
      // Specifies the current value
      Val := DBTab.Values[i, j];
      // Forms the current row
      TableRow := TableRow + ' ' + VarToStr(Val);
    end;
    // Posts the current row to the test log
    Log.Message(TableRow);
  end;

end;

C++Script, C#Script

function DBTableExample()
{
  // Specifies a DB Table element
  var DBTab = DBTables["Table1"];
  // Obtains the total number of rows
  // and columns of the table
  var RowNum = DBTab["RowCount"];
  var ColNum = DBTab["ColumnCount"];

  Log["Message"]("Number of rows:" + RowNum);
  Log["Message"]("Number of columns:" + ColNum);

  for (var i = 0; i < RowNum; i++)
  {
    var TableRow = "";
    for (var j = 0; j < ColNum; j ++)
    {
      // Specifies the current value
      var Val = DBTab["Values"](i, j);
      // Forms the current row
      TableRow = TableRow + " " + VarToStr(Val);
    }
    // Posts the current row to the test log
    Log["Message"](TableRow);
  }

}

See Also

About Database Checkpoints
Values Property
ValuesSelected Property
ColumnIndex Property
ColumnCount Property

Highlight search results