Showing posts with label fill. Show all posts
Showing posts with label fill. Show all posts

Sunday, February 19, 2012

country city area ..... help

hi all :

i am working in HR system , the user table is linked to the counter table and the city and the area tables . i want to fill this tables with all the country and cities and its area all over the world , i think that i could find such data on the internet , can any one help me how to find this tables and the data . beside the nationality table .... any help please

I am not sure you will get it on single location. May be wikipedia help you.. http://en.wikipedia.org/wiki/List_of_countries|||

And...

http://en.wikipedia.org/wiki/List_of_cities

Friday, February 17, 2012

Counting Result Set from SQL Query Before Fill()ing a DataSet

I need to display something like "Results x-y of z." The problem is, I can't figure out how to get the right value for z.

I am using SqlDataAdapter and Fill()ing a DataSet with subset x through y of the result set. How can I get the right value for z?

You are going to have to query the database to get the record number.

Select Count(OneOfYourFields) from YourTable.

You can command.executescalar to get the result

|||

Thank you for the reply.

I am using a Stored Procedure, so this makes things a bit more complicated. I know with MySQL you can use mysql_num_rows() to fetch the number of rows a query will return, without actually grabbing all the data from that query and pulling it onto the web server. Is there any similar functionality in C#/ASP.NET?

|||What ken means is that you need to run a count(*) query to retrieve the number of rows. ExecuteScalar will return the first record in the first row which is all you need since you only need the count. Then just display that number.|||I think I understood what Ken said. However, I am not just selecting from one table, I am executing a complicated Stored Procedure on multiple tables. How can I run a COUNT(*) on the Stored Procedure?|||

Hi,

As far as I know, we cannot run COUNT() on the result set of a stored procedure. The only way I think is to add some SELECT COUNT(*) for each table in the stored procedure and return the count as OUTPUT parameters.