.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

total no of tables in dataset

Posted By: Rama Krishna     Posted Date: July 15, 2011    Points:5   Category :ASP.Net
i want to find the total number of tables in dataset,and also to find how many records in each table?

Responses
Author: Amit Mehra             
Posted Date: July 15, 2011     Points: 20   

Hi Rama,

The answer of your question is The maximum size is limited by Int32 is 2^32.and Tables.Count property will return you an integer value and depending upon this it will return 2^32 tables in a DataSet

Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: Sasi Prabhu             
Posted Date: July 15, 2011     Points: 20   

Try

To Get No.of Tables in DataSet

Use : ds.Tables.Count;

To Get No.Of Rows in Table

Use : ds.Tables[0].Rows.Count;




Thanks & Regards,
Sasi Prabhu.
Author: Ravi Ranjan Kumar             
Posted Date: July 16, 2011     Points: 20   

hey! you can use Count property of DataSet.Tables class where Count is responsible to get total number of element in a collections.
as
int totaltable = dataSet.Tables.Count

and to get total no of Rows you need to use same Property named Count.
as
int totalrows = dataSet.Tables["TableName"].Rows.Count


and if you need to find selected value best on Condition then you can also use
or
dsDataSet.Tables["tablename"].Select("Use Appropriate Clause").Length;


its better to define Tablename instead of Index number.


Thanks & Regards
Ravi Ranjan Kumar
http://raviranjankr.wordpress.com
Author: Gowthammanju             
Posted Date: July 29, 2011     Points: 20   

try coding as

DataSet ds=new DataSet();
int count=ds.Tables.Count; //it will give the total number of tables in your dataset.

DataSet.Tables[0].Rows.Count //will give the number of rows in that table


Thanks & Regards,
GowthamManju
Chennai



Mark if the answer is true
Author: Gowthammanju             
Posted Date: July 29, 2011     Points: 20   

try these as

private void PrintRows(DataSet dataSet)
{
// For each table in the DataSet, print the row values.
foreach(DataTable table in dataSet.Tables)
{
foreach(DataRow row in table.Rows)
{
foreach (DataColumn column in table.Columns)
{
Console.WriteLine(row[column]);
}
}
}
}


Thanks & Regards,
GowthamManju
Chennai



Mark if the answer is true


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend