Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pass reference to datatable into function
#1
Solved: 6 Years, 6 Months, 3 Weeks ago
I wish to pass the name of a datatable into a function, such that the function can then retrieve values from said datatable. I tried passing the name as text, but it didn't work. I've also spent a fair amount of time looking around the web for different ideas, to no avail.

I suspect I need to pass the name as an object reference or perhaps a control, but i've never used OO before (although i've read a fair bit about it) and so i'm struggling. Is anyone able to point me in the right direction?

TIA
Reply
#2
Solved: 6 Years, 6 Months, 3 Weeks ago
Please show what you have tried.
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#3
Solved: 6 Years, 6 Months, 3 Weeks ago
Thanks for your assistance. As it happens, I managed to determine that my reference to the name of the datatable was missing a character, hence the reason it wasn't working. Doh!

For the benefit of others, I was calling a function and passing it the name of a particular datatable that I wanted it to collect information from:


Code:
myRtnVar = myFunction ("my_dt_name", myTestVariable)


Then, inside the function I wanted to use the forwarded dt reference (locally known as 'dtbl') to collect specific information from that dt. For example:


Code:
numOfRows = DataTable.GetSheet(dtbl).GetRowCount


I wasn't sure if it was even possible to do this in such a simplistic manner and so when it failed, I failed to spot the obvious error. Anyway, it works fine now that I have used the correct name.

Thanks again.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Automate Datatable column name and sheetname in function syednaqvi 1 1,377 06-07-2017, 01:46 PM
Last Post: Ankur
  Calling a Function in Function Library when function is defined in an Action jitenderkkr 0 2,764 11-27-2014, 12:53 PM
Last Post: jitenderkkr
  Can you please help me in QTP DP to pass the variable name anshika.agarwal 1 2,588 09-04-2014, 06:43 PM
Last Post: anshika.agarwal
  How to identify the object reference to the existing(already opened) Excel sheet yogeesh 1 9,765 09-26-2012, 07:00 PM
Last Post: krr
  Pass "/" in Query string to DB Anjali09 0 2,460 01-04-2012, 08:34 PM
Last Post: Anjali09

Forum Jump:


Users browsing this thread: 1 Guest(s)