Micro Focus QTP (UFT) Forums
HELP...... - 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: HELP...... (/Thread-HELP)



HELP...... - romel19 - 12-17-2012

in this script(below) i am not being able to use GetRowCount method as you can see before for loop i have two lines commented out where i tried to use GetRowCount method to run the script as many rows as it will get imported to the data table but couldn't. I had to use the actual number for the rows. what could be the reason? can anyone please help me solve this? and please if anyone could tell me if i wanted to use this for loop in function (as it show in the script on the top) instead of in the actual script what should be done?

thank you so much

btw i m using qtp 10 on win xp on ie6
Code:
'Declaring the function
Function getdtvalue(mycoln)

'Add data sheet in the QTP Data Table
DataTable.AddSheet ("mydt")

'Import the excel sheet into QTP Data Table
DataTable.ImportSheet "C:\Documents and Settings\Administrator\Desktop\QTP\MyTests\Data Driven FrameWork With Excel\Data\TC_Gmail_Login.xls", tcnameinexcel,"mydt"

getdtvalue=DataTable.Value(mycoln,"mydt")


End Function

'dt=Datatable.GetSheet("mydt").GetRowCount
'msgbox dt
For a=1 to 2
Datatable.SetCurrentRow(a)
'Datatable.SetNextRow


tcnameinexcel=Environment.Value("TestName")


systemutil.Run "iexplore.exe", getdtvalue("URL")
Browser("Browser").Page("Gmail: Email from Google").WebEdit("Email").Set getdtvalue("UserID")
Browser("Browser").Page("Gmail: Email from Google").WebEdit("Passwd").Set getdtvalue("password")
wait 2
Browser("Browser").Page("Gmail: Email from Google").WebButton("Sign in").Click
Browser("Browser").Page("Gmail - Inbox").Link("Sign out").Click
Browser("Browser").Page("Gmail: Email from Google_2").Sync
Browser("Browser").Close

next



RE: HELP...... - udayanem - 12-17-2012

You cant get the rowcount because, In "getdtvalue" method you are importing the data, whereas you are trying to find our the rowcount before it is called.

Move ImportSheet method(and corresponding steps) from the function and put it before the getrowcount method. You should be good to go.

Regards,
Uday