Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use Array of Array in QTP
#1
Not Solved
Hi, I am new in QTP. In MsAccess table , Column Name & data of each coulmn present. Eg. SrNo = 1, Name = Test etc..

How to use array of array to get column name & value .
Here is a code I have written.

Code:
Dim  arrRowVal() , arrColName()
FieldsCount =  rs.Fields.Count-1    'MsAccess table field count

' stored all column names in array arrColName()
For intColumn = 0 To FieldsCount
    ReDim  Preserve arrColName(intColumn)
             strColumnName =  rs.Fields(intColumn).Name
    arrColName(intColumn) = Cstr(strColumnName)
    MsgBox(  "strColumnName    : " & arrColName(intColumn))
Next
' store value of column name in arrRowVal
For intColumn = 0 To  FieldsCount
    ReDim Preserve  arrRowVal(intColumn)  
    strColumnValue = rs.Fields(intColumn).Value
    arrRowVal( arrColName(intColumn))=    strColumnValue  '**Here is problem
    
Next


**Here is problem : Displayed following error

Type mismatch: 'SrNo'
Function file: C:\DF.qfl
Line (152): " arrRowVal( arrColName(intColumn))= strColumnValue".

Please let me know how to solve the problem.

Thanks in Advance.
Dinesh
Reply
#2
Not Solved
First of all to save some time not sure how much.

instead of

Code:
For intColumn = 0 To FieldsCount
ReDim Preserve arrColName(intColumn)

I would do

Code:
ReDim arrColName(FieldsCount)
For intColumn = 0 To FieldsCount

Second have arrColName(intColumn) as a string instead of a number.

So if I knew this was a number this is what I suggest doing, though I'm really not sure what you are trying to accomplish. Note, if this value happens to not be a number this will still fail.
Code:
arrRowVal( CInt(arrColName(intColumn)))= strColumnValue
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  QTP/UFT - Storing Multiple Arrays In An Array Eitel13 0 1,635 07-17-2018, 04:37 PM
Last Post: Eitel13
  array to be captured and displayed Anu209 0 1,153 06-24-2017, 10:19 AM
Last Post: Anu209
  Unable to use array in QTP amit25007 2 3,164 01-25-2016, 05:10 PM
Last Post: amit25007
  Use WebEdit object as array sram3003 0 1,848 02-24-2015, 02:03 PM
Last Post: sram3003
  XML Data read and extract output in an array SweetyChowdhury 9 7,361 05-10-2013, 03:05 PM
Last Post: SweetyChowdhury

Forum Jump:


Users browsing this thread: 1 Guest(s)