QTP Script to get datatable column count
Syntax:-DataTable.GetSheet("sheet name"/sheetid).getparametercount
Example:-DataTable.GetSheet(1).getparametercount
Script to add new parameter(column)to datatable
Syntax:-DataTable.GetSheet("sheet name"/sheetid).AddParameter "columnname","value"
Example:-DataTable.GetSheet(1).AddParameter "AAA","4"
QTP Script to get all parameter(column)names
For i=1 to a
b=DataTable.GetSheet(1).GetParameter(i).Name
msgbox (b)
Next
where a=parametercount(columncount)
To get rowcount of datatable
DataTable.GetRowCount
Datatable Methods
QTP Script to get DataTable ColumnCount,Adding new Column to Datatable,Getting Datatable Column Names
Datatable Methods(2)
For first part of this post check Datatable Methods(1)
SetCurrentRow:-This method is used for setting the focus of QTP to a specified row.
Syntax:-DataTable.SetCurrentRow(RowNumber)
Example:-DataTable.SetCurrentRow(1)
SetPrevRow:-This method is used for setting the focus of QTP to the previous row of the currently focused row.
Syntax:-DataTable.SetPrevRow
Example:-DataTable.SetPrevRow
SetNextRow:-This method is used for setting the focus of QTP to the next row of the currently focused row.
Syntax:-DataTable.SetNextRow
Example:-DataTable.SetNextRow
GetSheet:-This method is used for making QTP to focus on a specified sheet.
Syntax:-DataTable.GetSheet(SheetId)
Example:-DataTable.GetSheet(1)
GetSheetCount:-This method is used to get count(number) of sheets in datatable.
Syntax:-DataTable.GetSheetCount
Example:-DataTable.GetSheetCount
GetRowCount:-This method is used for getting row count of a sheet.
Syntax:-DataTable.GetRowCount
Example:-DataTable.GetRowCount
By default it will get row count of Globalsheet.
If u want to get row count of a specified sheet then we have to use GetSheet method.
Syntax:-DataTable.GetSheet(SheetId).GetRowCount
Example:-DataTable.GetSheet(2).GetRowCount
Value:-It is used for capturing a value from a specified column,specified sheet and currently focused row.
Syntax:-DataTable.Value("column name"/column id,SheetId)
Example:-DataTable.Value("A",2) or DataTable.Value(1,2)