Page 1 of 1

How to Find tottal number of row present in Table

Posted: Wed Nov 12, 2014 8:33 am
by NishantSingh
Hi,

I am working on a .net Application, So this application when we add a data it will create a row in the table.
I want to know the total number of row a table have. So what code or function should I use.

OS: Windows 7
Ranorex Studio 5.2

Please help me out in this

Table Snapshot attached

Regards,
Nishant Singh

Re: How to Find tottal number of row present in Table

Posted: Wed Nov 12, 2014 9:08 am
by odklizec
Hi,

You can find an example of table reading/manipulation code here:
http://www.ranorex.com/support/user-gui ... html#c7781

Basically, the code for extracting the number of table rows is this:
tableAdapter.Rows.Count

So all you need to do is to get that example code and reduce it to bare minimum ;)

Eventually, you can use this code:

Code: Select all

    public void TableRowsCount_Repo(Ranorex.Adapter repoItem)
    {  
		// cast repoItem to Table (where the repoItem is table name stored in repository) 
		Ranorex.Table table = repoItem.As <Ranorex.Table>();
		int tableRowsCount = table.Rows.Count;
		Ranorex.Report.Log (ReportLevel.Success, "Table Rows count:" + tableRowsCount.ToString());
    } 

Re: How to Find tottal number of row present in Table

Posted: Wed Nov 12, 2014 12:47 pm
by NishantSingh
Thanks a lot yes its woking fine.

Regards,
Nishant Singh