How to DataAdapter Update Command - OLEDB

OleDbDataAdapter is a part of the ADO.NET Data Provider. The OleDbDataAdapter uses the Connection object of the .NET Framework data provider to connect to a data source and Command objects to retrieve data from and resolve changes to the data source. 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 C# code samples demonstrate how to use the OleDbDataAdapter object to update an OLEDB Data Source using UpdateCommand properties .

using System;
using System.Data;
using System.Data.OleDb;
using System.Windows.Forms;

namespace WindowsApplication1
    public partial class Form1 : Form
        public Form1()

        private void button1_Click(object sender, EventArgs e)
            string connetionString = null;
            OleDbConnection connection ;
            OleDbDataAdapter oledbAdapter = new OleDbDataAdapter();
            string sql = null;
            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'";
                oledbAdapter.UpdateCommand = connection.CreateCommand();
                oledbAdapter.UpdateCommand.CommandText = sql;
                MessageBox.Show ("Row(s) Updated !! ");
            catch (Exception ex)
} (C) 2021    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About