C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Create a DataTable, add rows and read records


Posted Date: 19 Mar 2007    Resource Type: Code Snippets    Category: ADO.NET

Posted By: ashish payghan       Member Level: Bronze
Rating:     Points: 10



This code sample shows how to create a DataTable, add some rows and read from it.

							
private DataTableReader GetDataTableReader()
{
DataTable tbl = new DataTable("tblUsers");
tbl.Columns.Add("FirstName");
tbl.Columns.Add("LastName");
for (int i = 1; i <= 100; i++)
{
DataRow rowNew = tbl.NewRow();
rowNew["FirstName"] = "First " + i.ToString();
rowNew["LastName"] = "Last " + i.ToString();
tbl.Rows.Add(rowNew);
}
return tbl.CreateDataReader();
}

private void Start()
{
DataTableReader reader = this.GetDataTableReader();
while (reader.Read())
{
Console.WriteLine(reader["FirstName"].ToString());
}
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: ADO.NET through connected architecture
Previous Resource: Binding data to a DataGrid
Return to Discussion Resource Index
Post New Resource
Category: ADO.NET


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

email fax service

Contact Us    Privacy Policy    Terms Of Use