Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9115073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:20:40+00:00 2026-06-17T04:20:40+00:00

I’ve been reading through the MSDN resources and several forums and still don’t understand

  • 0

I’ve been reading through the MSDN resources and several forums and still don’t understand what’s the difference between those two dataAdapter.Fill() and dataAdapter.Update(), I tried to use both of them to update the database from my program and it works, but when I try to remove the update() function, it is still working perfectly, therefore I think of it as useless.

Can anyone please clarify this?

Edit:
this is my code to delete:

string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Public\\Documents\\inventorySystem\\branches\\Database\\inventorySystemDatabase.accdb";
string query = "DELETE FROM Product WHERE product_id=" + productDataGridView[1, e.RowIndex].Value.ToString();
OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString);
OleDbCommandBuilder deleteBuilder = new OleDbCommandBuilder(dAdapter);
DataTable deleteTable = new DataTable();
dAdapter.Update(deleteTable);

— I have to make an extra select command to update the datagridview —

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:20:41+00:00Added an answer on June 17, 2026 at 4:20 am

    Working sample

    using System;
    using System.Data;
    using System.Windows.Forms;
    using System.Data.OleDb;
    
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            private OleDbConnection con =
                new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"C:\\test.mdb\";");
    
            private OleDbDataAdapter adapter;
            DataTable table = new DataTable("person"); 
    
            public Form1()
            {
                InitializeComponent();
    
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                con.Open();
                ;
                adapter = new OleDbDataAdapter("select ID, p_name, p_age from person", con);
                adapter.Fill(table);
                OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);
                adapter.DeleteCommand = builder.GetDeleteCommand();
                adapter.UpdateCommand = builder.GetUpdateCommand();
                adapter.InsertCommand = builder.GetInsertCommand();
                dataGridView1.DataSource = table;
    
            }
    
            private void Form1_FormClosing(object sender, FormClosingEventArgs e)
            {
                con.Close();
                con.Dispose();
            }
    
            private void btnDelete_Click(object sender, EventArgs e)
            {
                DataRow[] row = table.Select("p_age = 10");
                if (row.Length > 0)
                {
                    for (int i = 0; i < row.Length; i++)
                    {
                        row[i].Delete();
                    }
                }
                adapter.Update(table);
            }
    
        }
    }
    

    In simple words.

    DataAdapter.Fill() is used to load data from database

    Example : Showing Data From database to gridview

    using (DataTable table = new DataTable()) {
    
        using (OleDbDataAdapter adapter = new OleDbDataAdapter("select name,age from person", conObject)) {
    
            adapter.Fill(table);
            BindingSource bs = new BindingSource { DataSource = table };
            dgReader.DataSource = bs;    
        }
    
    }
    

    and once the edits are done, the DataAdapter.Update() commits all the changed data information to the database using the underlying connection.

    DataAdapter.Fill()

    The Fill method retrieves rows from the data source using the SELECT
    statement specified by an associated SelectCommand property. The
    connection object associated with the SELECT statement must be valid,
    but it does not need to be open. If the connection is closed before
    Fill is called, it is opened to retrieve data, then closed. If the
    connection is open before Fill is called, it remains open.

    The Fill operation then adds the rows to destination DataTable objects
    in the DataSet, creating the DataTable objects if they do not already
    exist. When creating DataTable objects, the Fill operation normally
    creates only column name metadata. However, if the MissingSchemaAction
    property is set to AddWithKey, appropriate primary keys and
    constraints are also created.

    DataAdapter.Update()

    The update is performed on a by-row basis. For every inserted,
    modified, and deleted row, the Update method determines the type of
    change that has been performed on it (Insert, Update or Delete).
    Depending on the type of change, the Insert, Update, or Delete command
    template executes to propagate the modified row to the data source.
    When an application calls the Update method, the DataAdapter examines
    the RowState property, and executes the required INSERT, UPDATE, or
    DELETE statements iteratively for each row, based on the order of the
    indexes configured in the DataSet. For example, Update might execute a
    DELETE statement, followed by an INSERT statement, and then another
    DELETE statement, due to the ordering of the rows in the DataTable.

    It should be noted that these statements are not performed as a batch
    process; each row is updated individually. An application can call the
    GetChanges method in situations where you must control the sequence of
    statement types (for example, INSERT before UPDATE). For more
    information, see Updating Data Sources with DataAdapters (ADO.NET).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have been unable to fix a problem with Java Unicode and encoding. The
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am trying to loop through a bunch of documents I have to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.