Dataadapter UpdateCommand - Sql Server

SqlDataAdapter is an integral component of the ADO.NET Data Provider. It provides essential functionality for updating a database with data modifications performed on a DataSet object. The SqlDataAdapter achieves this through its InsertCommand, UpdateCommand, and DeleteCommand properties, which are specifically designed to handle database updates.

To illustrate the usage of the SqlDataAdapter object and its UpdateCommand properties for updating a SQL Server database, consider the following code samples:

Full Source VB.NET
Imports System.Data.SqlClient Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim connetionString As String Dim connection As SqlConnection Dim adapter As New SqlDataAdapter Dim sql As String connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password" connection = New SqlConnection(connetionString) sql = "update product set product_price = 1001 where Product_name ='Product7'" Try connection.Open() adapter.UpdateCommand = connection.CreateCommand adapter.UpdateCommand.CommandText = sql adapter.UpdateCommand.ExecuteNonQuery() MsgBox("Row updated !! ") Catch ex As Exception MsgBox(ex.ToString) End Try End Sub End Class