How to count the number of rows and display it

I am working on a desktop application that returns list of tables that have foreign keys in a datagrid by this function.

       public void GetPrimaryKeyTable()


        //An instance of the connection string is created to manage the contents of the connection string.
        var sqlConnection = new SqlConnectionStringBuilder();
        sqlConnection.DataSource = "";
        sqlConnection.UserID = "gp";
        sqlConnection.Password = "gp";
        sqlConnection.InitialCatalog = Convert.ToString(cmbDatabases.SelectedValue);
        string connectionString = sqlConnection.ConnectionString;

        SqlConnection sConnection = new SqlConnection(connectionString);

        //To Open the connection.

        //Query to select the table_names that have PRIMARY_KEYS.
        string selectPrimaryKeys = @"SELECT 
                                           CONSTRAINT_TYPE = 'PRIMARY KEY'
                                           TABLE_NAME <> 'dtProperties'
                                   ORDER BY 

        //Create the command object
        SqlCommand sCommand = new SqlCommand(selectPrimaryKeys, sConnection);

            //Create the dataset
            DataSet dsListOfPrimaryKeys = new DataSet("INFORMATION_SCHEMA.TABLE_CONSTRAINTS");

            //Create the dataadapter object
            SqlDataAdapter sDataAdapter = new SqlDataAdapter(selectPrimaryKeys, sConnection);

            //Provides the master mapping between the sourcr table and
            sDataAdapter.TableMappings.Add("Table", "INFORMATION_SCHEMA.TABLE_CONSTRAINTS");

            //Fill the dataset

            //Bind the result combobox with primary key tables
            DataViewManager dvmListOfPrimaryKeys = dsListOfPrimaryKeys.DefaultViewManager;
            dgResultView.DataSource = dsListOfPrimaryKeys.Tables["INFORMATION_SCHEMA.TABLE_CONSTRAINTS"];
        catch(Exception ex)
            //All the exceptions are handled and written in the EventLog.
            EventLog log = new EventLog("Application");
            log.Source = "MFDBAnalyser";
            //If connection is not closed then close the connection
            if(sConnection.State != ConnectionState.Closed)

Now I want to count the number of tables that fall in this category and display it in a lablel that this much of tables are under this category..

Can you guys please help me


I believe you can just use the DataSet.Tables.Count method.

Or, DataSet.Tables[i].Rows.Count

Need Your Help

MVC - Can I display Title and Massage on 1 View by 2 different Controllers?


I'm new to MVC and also new to Stackoverflow. I'm not working with any Database but I simply want to display Title and Massage on 1 View by 2 different Controllers. I want in my Index.cshtml file the

Moulding shapes out of empty tags. Code explanation required

html css css3 animation

I have been trying to figure out this piece of CSS animation .

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.