I want to check in the data table(Globalsheet) column exist
or not through script .If column not exist only proceeded
to next step Pls tell me how to proceeded?
Answers were Sorted based on User's Feedback
Answer / drew
Answer 1 is good if you don't have a lot of data to write to
the data table. I sometimes have 20 columns to write to and
to check for the column each time before writing the data
can take 2 or more seconds each (40 seconds for the entire
row)...way to long if doing a repetitive task.
Answer 3 won't work because you will get a QTP error on the
line "Val = DataTable("UserId", dtGlobalSheet)" if the
column doesn't exist. But you can use that error to make a
very speedy function to find out if the column exists:
If COM_DoesDataTableColumnExist("Global","Column1") Then
''Column Exists
Else
''Column Does Not Exist
End If
Public Function COM_DoesDataTableColumnExist(ByVal
strSheetName,ByVal strColumnName)
Dim blnReturnValue
Dim strTestColumn
Err.Clear
On Error Resume Next
strTestColumn =
DataTable.GetSheet(strSheetName).GetParameter(strColumnName).Name
If Err <> 0 Then
blnReturnValue = False
Else
blnReturnValue = True
End If
Err.Clear
COM_DoesDataTableColumnExist = blnReturnValue
End Function
| Is This Answer Correct ? | 21 Yes | 5 No |
Answer / ravi bandaru
Function isParameterExists(sheetName, paramName)
isParameterExists = FALSE
ParamTotal = DataTable.GetSheet("Global").GetParameterCount
For i = 1 To ParamTotal
value = DataTable.GetSheet("Global").GetParameter(i).Name
Msgbox value
If strComp(paramName,value)=0 Then
isParameterExists=TRUE
Exit Function
End if
Next
End Function
'Example:
If isParameterExists("Global","hh") then
msgbox "Patameter exists"
Else
msgbox "Patameter does not exist"
<Your statements>
End if
| Is This Answer Correct ? | 8 Yes | 2 No |
Answer / nani4urs
Hi ravi Please run above sript in qtp.
is it works?
| Is This Answer Correct ? | 3 Yes | 6 No |
Answer / garywu
Public Function existColumn(byval Sheetname,byval ColumnNum)
paramcount = DataTable.GetSheet
(Sheetname).GetParameterCount
If ColumnNum>paramcount then
existColumn=False
else
existColumn=True
End If
End Function
| Is This Answer Correct ? | 1 Yes | 6 No |
Answer / rajaputra
Try for this,
Val = DataTable("UserId", dtGlobalSheet)
If val=false Then
msgbox "Parameter does not exist"
Else
msgbox "Parameter exists"
End If
| Is This Answer Correct ? | 2 Yes | 12 No |
can we create recorset with out using database connection in vbscript?
How do you invoke any application and write a script to invoke QTP using VB Script.
X flies from Hyd to bangalore using different methods of transportation. write the test scenarios and test cases for this?
How to give a call to another action from one action?
How to add a runtime parameter to a datasheet?
Hi I am new to QTP. can u please answer to my qus... suppose 3 excel sheets are there * we are trying to check for login credentials for a page. userid from excel1 , password is from excel2 whether the page is opened or not that checkpoint is result is should be stored in excel 3.... this qus i have faced in IBM technical round... please tell script for above query ... please please
How many tables r created during the recording in QTP?
can we run the scripts of qtp 8.2 in the qtp7.0?
what is Smart identification
WHAT IS ENVIRONMENT VARIABLES?
7 Answers AZTEC, CTS, Ready Test Go,
If we are record a same web page for 2 times.1st time it is showing 6 objects in the Object Repository and for the 2nd time it is showing like 7 Objects in the Object Repository why it is happening
Please explain how to open with notepad of saved html file by right click option using QTP