Net-informations.com
SiteMap  | About    

Dataadapter UpdateCommand - OLEDB Data Source

OleDbDataAdapter is a part of the ADO.NET Data Provider. The InsertCommand, the UpdateCommand, and the DeleteCommand properties of the OleDbDataAdapter object update the Data Source with the data modifications that are run on a DataSet object.

The following code samples that demonstrate how to use the OleDbDataAdapter object to update an OLEDB Data Source using UpdateCommand properties in OleDbDataAdapter.




Imports System.Data.OleDb
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 OleDbConnection
        Dim oledbAdapter As New OleDbDataAdapter
        Dim sql As String
        connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your mdb filename;"
        connection = New OleDbConnection(connetionString)
        sql = "update Users set Password = 'new password' where UserID = 'user1'"
        Try
            connection.Open()
            oledbAdapter.UpdateCommand = connection.CreateCommand
            oledbAdapter.UpdateCommand.CommandText = sql
            oledbAdapter.UpdateCommand.ExecuteNonQuery()
            MsgBox("Row(s) Updated !! ")
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Class






net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.