title: Value cannot be null. Parameter name: dataSource. Editing Datagrid and Save to Database
body: <p>Hello I'm having a problem here. The code looks like this.</p>
  
  <pre><code>private void Form3_Load(object sender, EventArgs e)
  { 
       string connectionString =
       "Server=localhost;" +
       "Database=oroderm;" +
       "User ID=root;" +
       "Password=root;" +
       "Pooling=false";
       string query = "Select * from client";
       MySqlConnection conn = new MySqlConnection(connectionString);
       MySqlDataAdapter dAdapter = new MySqlDataAdapter(query, connectionString);
       conn.Open();
       DataSet ds = new DataSet();
       MySqlCommandBuilder cBuilder = new MySqlCommandBuilder(dAdapter);
  
       dAdapter.Fill(ds, "client");
  
       BindingSource bSource = new BindingSource();
       bSource.DataSource = ds.Tables["client"];
       dataGridView2.DataSource = bSource;
  }
  
  private void button1_Click(object sender, EventArgs e)
  {
       DataTable dt = ds.Tables["client"];
       this.dataGridView2.BindingContext[dt].EndCurrentEdit();
       this.da.Update(dt);
  }
  </code></pre>
  
  <p>So what I want is that whenever I edit the values in my Datagrid it will affect my database after I click button1 (save button). ex. If I have roman as the client after I changed his name and I click button1 it should change. However Im getting a value cannot be null error. Please can somebody help. T_T</p>
  
  <p>*EDIT: Heres the Updated Code</p>
  
  <pre><code>private MySqlDataAdapter _da;
          private DataTable _dt;
          private DataSet _ds;
  
   private void Form3_Load(object sender, EventArgs e)
          {
                 updateClient();
          }
  
  public void updateClient()
          {
              string connectionString =
               "Server=localhost;" +
               "Database=oroderm;" +
               "User ID=root;" +
               "Password=root;" +
               "Pooling=false";
  
              string query = "select * from client";
              MySqlConnection conn = new MySqlConnection(connectionString);
              _da = new MySqlDataAdapter(query, connectionString);
              conn.Open();
              _ds = new DataSet();
              MySqlCommandBuilder cBuilder = new MySqlCommandBuilder(_da);
  
              _da.Fill(_ds, "client");
              BindingSource bSource = new BindingSource();
              bSource.DataSource = _ds.Tables["client"];
              dataGridView2.DataSource = bSource;
              _da.UpdateCommand = cBuilder.GetUpdateCommand();
          }
  
  private void button1_Click(object sender, EventArgs e)
          {
  
              _dt = _ds.Tables["client"];
              this.dataGridView2.BindingContext[_dt].EndCurrentEdit();
              this._da.Update(_dt);
  
          }
  </code></pre>