Introduction:
Here we will see how to use update command in vb.net

Update command:
The update statement used to update existing records in a table.


update table1 set Firstname='darwin', Lastname='chaudhary' where City='roorkee' and Id='1'

For example:

Imports System.Data.SqlClient

Module Module1

Sub Main()

Dim str As String = "Data Source=.;uid=sa;pwd=Password$2;database=master"

Dim con As New SqlConnection(str)

Try

con.Open()

Dim com As New SqlCommand("update table1 set Firstname='darwin', Lastname='chaudhary' where City='roorkee' and Id='1' ", con)

Console.WriteLine("Number of row in table:=" & com.ExecuteScalar())

com.ExecuteNonQuery()

Console.WriteLine("update has been completed")

con.Close()

Catch ex As Exception

Console.WriteLine("can not update record")

End Try

End Sub

End Module