DataRow Class in VB.net
By: Steven Holzner
DataRow objects represent rows in a DataTable object. You use DataRow objects to get access to, insert, delete, and update the records in a table.
To create a new DataRow object, you usually use the NewRow method of a DataTable object, and after configuring the row with data, you can use the Add method to add the new DataRow to the table. In addition, you also can call the AcceptChanges method of the DataTable object to make that table treat the new row as it would its original data.
You can delete a DataRow from the Rows collection in a data table by calling the Remove method, or by calling the Delete method of the DataRow object itself. Note that the Remove removes the row from the collection, and the Delete method simply marks the DataRow for deletion. (The actual deletion occurs when you use the AcceptChanges method.)
So how do you actually get the data values stored in a particular field in a row? You can use the Item property, referring to the field by name or index. Here's how that looks in the ReadData example on the CD-ROM that we'll see in this chapter (see "Accessing Individual Data Items" in the Immediate Solutions):
For RowLoopIndex = 0 To (DataSet11.Tables("authors").Rows.Count - 1)
>
For ColLoopIndex = 0 To (DataSet11.Tables("authors").Columns.Count - 1)
TextBox1.Text &= _
DataSet11.Tables("authors").Rows(RowLoopIndex).Item(ColLoopIndex) & _
ControlChars.Tab & ControlChars.Tab
Next ColLoopIndex
TextBox1.Text &= ControlChars.CrLf
Next RowLoopIndex
Archived Comments
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Using Resume Next and Resume Line in VB.net
Using On Error GoTo 0 in VB.net
Getting an Exception's Number and Description in VB.net
Raising an Exception Intentionally in VB.net
Exception Filtering in the Catch Block in VB.net
Using Multiple Catch Statements in VB.net
Throwing an Exception in VB.net
Throwing a Custom Exception in VB.net
Changes in Controls from VB6 to VB.net
Unstructured Exception Handling in VB.net