Académique Documents
Professionnel Documents
Culture Documents
http://www.dotnetfunda.com/articles/article131.aspx
Home
Freshers
Career Advice
Articles
Interviews
Videos
Forums
Codes
Blogs
Jobs
Job Support
Community
Jokes
Chat
MVPs | ASP.NET, WPF, SSIS etc. tutorials | Catalog | Coding Horror | Downloads | Quick Links | Top Posts | Top Authors | .NET News | Bookmarks | Search | Subscribe
Online : 12238 | Welcome, Guest! Register Login Home > Articles > ADO.NET > DataTable - Adding, Modifying, Deleting, Filtering, Sorting rows & Reading/Writing from/to Xml Also read How to Serialize and DeSerialize an ArrayList having a custom object inside it | ListView Tips and Tricks | Generating XML from relational database tables
DataTable - Adding, Modifying, Deleting, Filtering, Sorting rows & Reading/Writing from/to Xml
Article posted by SheoNarayan on 9/3/2008 | Views: 365933 | Category: ADO.NET | Level: Intermediate
Tweet 26 Share 1 12
4 vote(s)
Rating: 5 out of 5
Submit Article |
Search Articles |
Articles Home |
Winners
In this article, I am going to explain how to Add, Modify, Delete, Sort, Filter rows of the DataTable and also loading data from xml and writing data into xml. I will also talk about writing/reading Schema of the DataTable.
Introduction
DataTable is a central object in the ADO.NET library. If you are working with ADO.NET - accessing data from database, you can not escape from DataTable. Other objects that use DataTable are DataSet and DataView. In this tutorials, I will explain how to work with DataTable. I have tried to cover most of the frequently used activity in the DataTable, I hope you will like it.
DotNetFunda on
Creating a DataTable
To create a DataTable, you need to use System.Data namespace, generally when you create a new class or page, it is included by default by the Visual Studio. Lets write following code to create a DataTable object. Here, I have pased a string as the DataTable name while creating DataTable object.
Avdhesh
Jitender
Ashish
31050
12250
10000
Ads
1 of 5
5/23/2012 1:27 PM
http://www.dotnetfunda.com/articles/article131.aspx
// specify it as auto increment field auto.AutoIncrement = true; auto.AutoIncrementSeed = 1; auto.ReadOnly = true; If you want a particular column to be a unique column ie. you don't want duplicate records into that column, then set its Unique property to true like below. auto.Unique = true;
Articles Categories .NET Framework Articles ADO.NET Articles ASP.NET Articles ASP.NET AJAX Articles ASP.NET MVC Articles Azure Articles Best Practices Articles BizTalk Server Articles C# Articles CMS Articles CSS Articles Error and Resolution Articles F# Articles Advertisements
2 of 5
5/23/2012 1:27 PM
http://www.dotnetfunda.com/articles/article131.aspx
3 of 5
5/23/2012 1:27 PM
http://www.dotnetfunda.com/articles/article131.aspx
Hope this article will be useful. If you have any question, comments or suggestions, please respond to this article. Thank you very much for reading it and Happy DataTable :)
.NET web programming Simplify your .NET web programming in C# or VB, with Jaxcent. www.jaxcent.com/ Chart Control for ASP.NET Full-Featured Web Charting Solution for ASP.NET Ajax Platform www.devexpress.com Image resizing on the fly Make high-quality image thumbnails with this ASP/ASP.NET component. www.aspjpeg.com
RSS Feed. You can also subscribe via email to our Interview Questions, Codes and
More | Bookmark It
Please Sign In to vote for this post. Latest Articles from SheoNarayan Customizing asp:Chart Label font styles and intervals etc. How to use Rotating, Skew and Multiple background image in CSS3? How to use Opacity, Scale and box shadow and Zooming in CSS 3? How to use Transition,Text-Shadow and Border-Radius effect in CSS 3? How to play audio in the HTML5 and how to control the audio play using in HTML element ? More from SheoNarayan ...
Responses
Posted by: Ankit.dadhich@yahoo.com | Posted on: 08 Jul 2010 02:47:28 AM thanks very helpful Posted by: Fxjamy | Posted on: 06 Sep 2010 02:43:49 AM | Points: 10 Hello, I was wondering if it is possible to style particular columns? Need to show Money symbol in some columns. Thanks Posted by: Lakhwinder.ghuman | Posted on: 23 May 2011 03:45:00 AM | Points: 25 too good.
4 of 5
5/23/2012 1:27 PM
http://www.dotnetfunda.com/articles/article131.aspx
Posted by: G | Posted on: 07 Jun 2011 10:29:50 PM | Points: 25 Following is the code that i currently have as an output from dataset. I used ds.writexml("FILENAME"); Cool. <SalesTransactions> <Transaction> <sale_tx_no>1002367</sale_tx_no> <sale_date>2008-01-14T15:37:07+13:00</sale_date> <loyalty_card>234234234234</loyalty_card> </Transaction> <SalesTransactions> But I want to change the names of allthe columns in this xml file as under: <SalesTransactions> <Transaction> <Reference>1002367</Reference> <DateofSale>2008-01-14T15:37:07+13:00</DateofSale> <Card>234234234234</Card> </Transaction> <SalesTransactions> Can someone help me out!! Posted by: TitoChhabra | Posted on: 15 Oct 2011 03:26:53 AM | Points: 25 Hi, Great job. Nice article. It's really very helpful for me. Here is also another nice article on datatable, you may check this url for more details ...... http://www.mindstick.com/Articles/4d0f2113-b3e8-4516-90f5-028adeaae201/?DataTable Thanks !! >> Write Response - Respond to this post and get points Latest Articles How to use String.Format function of C# in Javascript and display multiple values of a resource file. Working with Silverlight Datagrid Control MVC tutorial number 12 - What is RAZOR in MVC 3? Creating a circle with CSS How to validate using Data annotation(MVC tutorial number 11)? Invoke Javascript Methods from Silverlight Applications Invoke Silverlight Methods through Javascript How to create partial views (MVC tutorial number 10)? Create Chart in SSRS(RDLC) Report More ...
Related Posts
ADO.NET Interview Questions - Part 1 This is the Part 1 of ADO.NET. In this section we will touch base on one of important concepts in ADO.Net. Diff Between DataGrid and GridView Im going to expail the various difference between GridView and the DataGrid controls and their different logics. How to insert records into the database? In this article, we shall learn how to insert records into the SQL Server database. How to use transactions in ADO.NET? In this article, we shall learn how to use transactions in ADO.NET. CRUD Operations using ADO.net Entity Framework In this post I show you how to perform CRUD operations using ADO.net Entity Framework. A sample WPF application is available for download which shows this functionality More ... About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top General Notice: If you found plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/23/2012 3:22:48 AM
5 of 5
5/23/2012 1:27 PM