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



I want to check in the data table(Globalsheet) column exist or not through script .If column not ..

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

I want to check in the data table(Globalsheet) column exist or not through script .If column not ..

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

I want to check in the data table(Globalsheet) column exist or not through script .If column not ..

Answer / nani4urs

Hi ravi Please run above sript in qtp.
is it works?

Is This Answer Correct ?    3 Yes 6 No

I want to check in the data table(Globalsheet) column exist or not through script .If column not ..

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

I want to check in the data table(Globalsheet) column exist or not through script .If column not ..

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

Post New Answer

More QTP Interview Questions

How do Parameterization and Data-Driving relate to each other in QTP?

0 Answers  


Tell some commonly used Excel VBA functions?

0 Answers  


If I change the property value at runtime is it effect is object repository?

0 Answers  


How to invoke Mozilla from QTP thru VB Script

2 Answers  


A web Page has 2 frames. Find out the number of weblist items in the second frame of the page.

2 Answers   Virtusa,






Recovery Manager means..?

4 Answers  


what is Unicoad Compatibility ???? HOw does this makes a diffrence from Winrunner.???

1 Answers   GE,


How can i initiate the objects to find uniquely in OR

0 Answers   IBM, Livetek,


How do we edit the script in QTP. Anybody can explain in detail..Thanks in advacne...

3 Answers   IBM,


How to integrate QTP with QC using VB Scripting? What are the prerequisites to connect with QC?

0 Answers   CTS, Nabard,


Give me detailed theritical explanation about keyword driven, hybrid framework, environment variables, hybrid frame work

0 Answers   TCS,


How to open a new test using quicktest professional?

0 Answers  


Categories