Micro Focus QTP (UFT) Forums
Column Names in DataTable within QTP - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Column Names in DataTable within QTP (/Thread-Column-Names-in-DataTable-within-QTP)



Column Names in DataTable within QTP - vijayendra.shukla - 02-26-2010

Hi,

I was trying use the below code to set values in DataTable

Code:
DataTable("A", Action1") = 2010
But i am getting error "The set DataTable.Value operation failed. The <A> column does not exist."

When i renamed this column it worked.
Is it the displayed column names in the DataTable are not really the column names like in excel sheet??? Because when i renamed this column to "A" (which was already getting displayed in DataTable) it worked.


RE: Column Names in DataTable within QTP - Saket - 02-26-2010

Datatable columns can not be said as columns as we say in the excel.
In QTP we say it - 'Parameter'
Datatable will set a value in any of the column that you see there until it is specified as parameter
refer Parameterization in QTP help for more details


RE: Column Names in DataTable within QTP - Jackomcnabb - 02-26-2010

I had an issue where I was missing, as I was running the same code for a number scripts and I built columns on the fly if they where missing, this maybe or not helpful:

Code:
ColNums=DataTable.GetSheet(dtGlobalSheet).getparametercount
For i=1 to ColNums
ColName=DataTable.GetSheet(dtGlobalSheet).GetParameter(i).Name
Next


If ColName <> Col3  Then
DataTable.GetSheet(dtGlobalSheet).AddParameter "Col3","Test this Col 3"
End If
If  ColName <> Col4  Then
DataTable.GetSheet(dtGlobalSheet).AddParameter "Col4","Test this Col 4"
End If

Test1=DataTable("Col3", dtGlobalSheet)
Test2=DataTable("Col4", dtGlobalSheet)

msgbox(Test1)
msgbox(Test2)



RE: Column Names in DataTable within QTP - perplexed - 05-27-2011

thanks jackomcnabb. It definately helped.