DataTable related operations

Created by akaBot Support, Modified on Thu, 8 Aug, 2024 at 2:31 PM by akaBot Support

We will introduce some typical data table related operations using the methods and properties of the DataTable Class 

No
Operation Description
Processing Function
1
Retrieve a DataColumn from a DataTable variable
DataTable.Columns(columnIndex)
2-1
Retrieve a DataRow from a DataTable variable
DataTable.Rows(rowIndex)
2-2
Retrieve values from the obtained DataRow
DataTable.Rows(rowIndex).Item(columnIndex)

Example DataTable (variable name: DataTable):

No
Name
Price
Stock
1
Strawberry
200
30
2
Apple
100
50
3
Peach
150
20
4
Orange
100
50
5
Grape
200
15


1. Retrieve a DataColumn from a DataTable Variable

Example: To retrieve the first DataColumn

DataTable.Columns(0) 

Note: Column index starts from 0.

Message Box Input Example

Output Example

Refer to the DataTable.Columns property (Microsoft) for more details.



2. Manipulate DataRow

2-1. Retrieve a DataRow from a DataTable Variable

Example: DataTable.Rows(0)

In this case, the following part of the above data table is retrieved:

1
Strawberry
200
30

Refer to the DataTable.Rows property (Microsoft) for more details.

2-2. Retrieve Values from a DataRow

Example: DataTable.Rows(0).Item(1)

Message Box Input Example

Output Example

Refer to the DataRow.Item property (Microsoft) for more details.







Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article