c# - How to count the number of rows and display it -


i working on desktop application returns list of tables have foreign keys in datagrid function.

       public void getprimarykeytable()          {          //an instance of connection string created manage contents of connection string.         var sqlconnection = new sqlconnectionstringbuilder();         sqlconnection.datasource = "192.168.10.3";         sqlconnection.userid = "gp";         sqlconnection.password = "gp";         sqlconnection.initialcatalog = convert.tostring(cmbdatabases.selectedvalue);         string connectionstring = sqlconnection.connectionstring;          sqlconnection sconnection = new sqlconnection(connectionstring);          //to open connection.         sconnection.open();          //query select table_names have primary_keys.         string selectprimarykeys = @"select                                             table_name                                                                                    information_schema.table_constraints                                                                                    constraint_type = 'primary key'                                         ,                                            table_name <> 'dtproperties'                                    order                                             table_name";          //create command object         sqlcommand scommand = new sqlcommand(selectprimarykeys, sconnection);          try             {             //create dataset             dataset dslistofprimarykeys = new dataset("information_schema.table_constraints");              //create dataadapter object             sqldataadapter sdataadapter = new sqldataadapter(selectprimarykeys, sconnection);              //provides master mapping between sourcr table , system.data.datatable             sdataadapter.tablemappings.add("table", "information_schema.table_constraints");              //fill dataset             sdataadapter.fill(dslistofprimarykeys);              //bind result combobox primary key tables             dataviewmanager dvmlistofprimarykeys = dslistofprimarykeys.defaultviewmanager;             dgresultview.datasource = dslistofprimarykeys.tables["information_schema.table_constraints"];             }         catch(exception ex)             {             //all exceptions handled , written in eventlog.             eventlog log = new eventlog("application");             log.source = "mfdbanalyser";             log.writeentry(ex.message);             }                     {             //if connection not closed close connection             if(sconnection.state != connectionstate.closed)                 {                 sconnection.dispose();                 }             }         } 

now want count number of tables fall in category , display in lablel of tables under category..

can guys please me

i believe can use dataset.tables.count method. http://msdn.microsoft.com/en-us/library/system.data.internaldatacollectionbase.count.aspx

or, dataset.tables[i].rows.count


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -