Updating Datagridview content in c# when there is conditions on input
<p>I have AddEmp button for inserting  data by user ,but on this AddEmp button i have conditions,so in datagridview when i try to update content using given below code it is throwing me an exception ,but when i use same code for AddMoey button i am able to update content shon in datagridvie since this button doesn't have any condition,so how can i solve this problem?my code is like this for Updating datagridview content and for AddEmp                                                                                      </p>

<pre><code>private void UpdateDatagridviewcontent_Click(object sender, EventArgs e)
        {
            dAdapter.Update(dTable);
        }

private void AddEmp_Click(object sender, EventArgs e)
        {
            DBHandling db = new DBHandling();
            if(name.Text.Trim().Equals(""))
            {
                name.Focus();
                MessageBox.Show("Name cannot be blank!");
            }
            else if(Payment.Text.Trim().Equals(""))
            {
                Payment.Focus();
                MessageBox.Show("Payment cannot be blank!");
            }
            else if (!IsNumeric(Payment.Text.Trim()))
            {
                Payment.Focus();
                MessageBox.Show("Payment should contain Numerical Values!");
            }
                else if(CellNumber.Text.Trim().Equals(""))
            {
                CellNumber.Focus();
                MessageBox.Show("Cell Number cannot be blank!");

            }
            else if (!IsNumeric(CellNumber.Text.Trim()) || CellNumber.Text.Trim().Length&lt;10)
            {
                CellNumber.Focus();
                MessageBox.Show("Invalid Cell Number!");
            }
            else if(JoiningDate.Text.Trim().Equals(""))
            {
                JoiningDate.Focus();
                MessageBox.Show("set Joining Date!");
            }             
            else
            {
                db.AddEmp(name.Text, Payment.Text, CellNumber.Text, Education.Text, JoiningDate.Text);
                MessageBox.Show("Employee added successfully!");
            }
            name.Clear();           
            Payment.Clear();           
            CellNumber.Clear();            
            Education.Clear();
            name.Focus();

        }

                                                                                        Thanks in advance.
</code></pre>

<p>Update from comment:</p>

<p>this code is for datagridview,and DBHandling is class in which i have add_emp method:</p>

<pre><code>private void ShowEmp_Load(object sender, EventArgs e)
{
  connectionString = GetConnectionString();connection = new sqlConnection(connectionString);
  queryString = "select Emp.name,Addm.Date,AddDate.LeavingDate from Emp,Addm,AddDate where name.Text='" + name + " ' ";
  dAdapter = new SqlDataAdapter(queryString, connection);
  cBuilder = new SqlCommandBuilder(dAdapter);
  dTable = new DataTable();
  dAdapter.Fill(dTable);
  bSource = new BindingSource();
  bSource.DataSource = dTable;
  dataGridView1.DataSource = bSource;
}
</code></pre>
