How to: Update a DataRow with the Value from a Variable (Visual Basic) 

This example assigns the value in the companyName variable to the CompanyName data column of dataRow.

Example

Dim companyName As String = "Microsoft"
Dim dataRow As DataRow = dsNorthwind1.Customers(0)
dataRow("CompanyName") = companyName

Compiling the Code

This example requires:

  • A project reference to System.data.dll.

  • Access to the members of the System.Data namespace. Add an Imports statement if you are not fully qualifying member names in your code. For more information, see Imports Statement.

  • An instance of a typed dataset named dsNorthwind1.

  • A data table named Customers in the dsNorthwind1 dataset.

  • A DataColumn named CompanyName in the Customers table.

  • At least one DataRow in the Customers table.

Robust Programming

The following conditions may cause an exception:

See Also

Reference

DataRow Class
DataColumn Class

Concepts

Saving Data Overview

Other Resources

Preparing Your Application to Receive Data
Editing Data in Your Application