ColumnCount Property

Applies to TestComplete 15.40, last modified on March 25, 2022

Description

Project, project suite and keyword test variables of the DB Table type store the link to the data storage to whose contents the variables provide access. The ColumnCount property returns the number of columns in the data storage DBTableVariableObj provides access to.

Declaration

DBTableVariableObj.ColumnCount

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

Applies To

The property is applied to the following object:

Property Value

An integer value that specifies the number of columns in the data storage.

Example

The code below obtains the total number of columns stored in the DBVar1 variable and then posts the names of these columns to the test log.

JavaScript, JScript

function DBTableVar()
{
  // Obtains a DB Table variable
  var DBTab = Project.Variables.DBVar1;
  // Initializes the iterator
  DBTab.Reset;
  // Obtains the total number of the table's columns
  var ColNum = DBTab.ColumnCount;
  
  // Iterates through the table's columns
  for (var i = 0; i < ColNum; i++)
  {
    var ColName = DBTab.ColumnName(i);
    Log.Message("The name of column " + (i+1) + " is: " + ColName);
  }
}

Python

def DBTableVar():
  # Obtains a DB Table variable
  DBTab = Project.Variables.DBVar1
  # Initializes the iterator
  DBTab.Reset()
  # Obtains the total number of the table's columns
  ColNum = DBTab.ColumnCount
  # Iterates through the table's columns
  for i in range(0, ColNum):
    ColName = DBTab.ColumnName[i]
    Log.Message("The name of column " + str(i + 1) + " is: " + ColName)

VBScript

Sub DBTableVar

  ' Obtains a DB Table variable
  Set DBTab = Project.Variables.DBVar1
  ' Initializes the iterator
  DBTab.Reset
  ' Obtains the total number of the table's columns
  ColNum = DBTab.ColumnCount
  
  ' Iterates through the table's columns
  For i = 0 to (ColNum - 1)
    ColName = DBTab.ColumnName(i)
    Log.Message("The name of column " & (i+1) & " is: " & ColName)
  Next

End Sub

DelphiScript

function DBTableVar;
var DBTab, ColNum, i, ColName;
begin

  // Obtains a DB Table variable
  DBTab := Project.Variables.DBVar1;
  // Initialize the iterator
  DBTab.Reset;
  // Obtains the total number of the table's columns
  ColNum := DBTab.ColumnCount;
  
  // Iterates through the table's columns
  for i := 0 to (ColNum - 1) do
  begin
    ColName := DBTab.ColumnName[i];
    Log.Message('The name of column ' + (i+1) + ' is: ' + ColName);
  end;

end;

C++Script, C#Script

function DBTableVar()
{
  // Obtains a DB Table variable
  var DBTab = Project["Variables"]["DBVar1"];
  // Initialize the iterator
  DBTab["Reset"];
  // Obtains the total number of the table's columns
  var ColNum = DBTab["ColumnCount"];
  
  // Iterates through the table's columns
  for (var i = 0; i < ColNum; i++)
  {
    var ColName = DBTab["ColumnName"](i);
    Log["Message"]("The name of column " + (i+1) + " is: " + ColName);
  }
}

See Also

Variables of the DB Table Type
ColumnName Property
Value Property

Highlight search results