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

  • Home
  • SEARCH
  • 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 9241409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:22:03+00:00 2026-06-18T08:22:03+00:00

Unable to update changes to database after editing the gridview. There are no errors

  • 0

Unable to update changes to database after editing the gridview. There are no errors thrown, but changes are not updated in table in database. I am using Sql server here and I have two Winforms called Form1 and Form 2. A button(btnSearchAll in Form1) opens the gridview in Form2 with all the data loaded. When I try to edit the data in gridview(in Form2) and tried to update, it is not updating the changes. Please help

Below is my Form 1:

    namespace Tailor_app
{
    public partial class Form1 : Form
    {
        DataSet ds = new DataSet();
        SqlConnection con = new SqlConnection("server=(local);Database=MSNETDB;Integrated Security=true;");
        SqlDataAdapter da;
        DataTable dt;

    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        //SqlConnection con = new SqlConnection("server=(local);Database=MSNETDB;Integrated Security=true;");
        txtFirstName.Focus();
        da = new SqlDataAdapter("select * from Measurement", con);
        da.Fill(ds, "Measurement");
        dt = ds.Tables["Measurement"];
        SqlCommandBuilder cb = new SqlCommandBuilder(da);
        cb.ConflictOption = ConflictOption.CompareAllSearchableValues;
    }

    private void btnSave_Click(object sender, EventArgs e)
    {
            DataRow dr = dt.NewRow();
            dr["CellNumber"] = txtCellNo.Text.Trim();
            dr["FirstName"] = txtFirstName.Text;
            dr["LastName"] = txtLastName.Text;
            dr["Shirt"] = txtShirt.Text;
            dr["Pant"] = txtPant.Text;
            dr["DueDate"] = txtDueDate.Text;
            dr["Date"] = txtDate.Text;
            if (dr["CellNumber"] == "")
            {
                MessageBox.Show("Please enter Cell Number");
            }
            else if (dr["CellNumber"] != "")
            {
                dt.Rows.Add(dr);
                MessageBox.Show("Success");
            }

                try
                {
                    da.Update(ds, "Measurement");
                }
                catch (DBConcurrencyException ex)
                {
                    MessageBox.Show(ex.Message);
                    dt.Clear();
                    da.Fill(ds, "Measurement");
                }
        }

    private void btnSearchAllCustomers_Click(object sender, EventArgs e)
    {
        this.Hide();
        frmDgv_SearchResult frm2 = new frmDgv_SearchResult();
        frm2.Show();

        using (da = new SqlDataAdapter())
        {
            try
            {
                da.SelectCommand = new SqlCommand("Select * From Measurement", con);
                ds.Clear();
                da.Fill(ds,"Measurement");
                dt = ds.Tables["Measurement"];
                frm2.dgvSearchResults.DataSource = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
    }
}

}

Below is my Form 2:

namespace Tailor_app
{

public partial class frmDgv_SearchResult : Form
{
    DataSet ds = new DataSet();
    SqlConnection con = new SqlConnection("server=(local);Database=MSNETDB;Integrated Security=true;");
    SqlDataAdapter da;
    DataTable dt;

    public frmDgv_SearchResult()
    {
        InitializeComponent();
    }

    private void dgvSearchResults_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {

    }

      private void frmDgv_SearchResult_Load(object sender, EventArgs e)
    {
        da = new SqlDataAdapter("select * from Measurement", con);
        da.Fill(ds, "Measurement");
        dt = ds.Tables["Measurement"];
        SqlCommandBuilder cb = new SqlCommandBuilder(da);
        cb.ConflictOption = ConflictOption.CompareAllSearchableValues;
    }

    private void btnUpdate_Click(object sender, EventArgs e)
    {
        try
            {
                da.Update(ds, "Measurement");
            }
            catch (DBConcurrencyException ex)
            {
                MessageBox.Show(ex.Message);
                dt.Clear();
                da.Fill(ds, "Measurement");
            }
            finally
            {
                MessageBox.Show("success");
            }
        }
  • 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-18T08:22:04+00:00Added an answer on June 18, 2026 at 8:22 am

    Try requesting the Update commands for your Data Adapter :-

      private void frmDgv_SearchResult_Load(object sender, EventArgs e)
        {
            da = new SqlDataAdapter("select * from Measurement", con);
            da.Fill(ds, "Measurement");
            dt = ds.Tables["Measurement"];
            SqlCommandBuilder cb = new SqlCommandBuilder(da);
    
            cb.GetInsertCommand();
            cb.GetUpdateCommand();
            cb.GetDeleteCommand();
    
            cb.ConflictOption = ConflictOption.CompareAllSearchableValues;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to update database table based on text-box values.But i am unable
I am unable to build my app because R.java will not update the ids.
I am unable to set my inbuilt database to update . It is always
using Microsoft.SqlServer.Management.SqlStudio.Explorer; unable to find this pls assist [update] found the dll's in this
I'm unable to run any selenium tests since I updated Firefox to 3.6. Is
I'm getting an Unable to obtain public key for StrongNameKeyPair. exception using Newtonsoft's JsonConvert.SerializeObject
am getting there with jqgrid, although i am still unable to save row data
I have a mysql table like this (sql): CREATE TABLE IF NOT EXISTS silver_and_pgm
I'm new to Git and Github. I created a repository but am unable to
This is pretty easy question, but I have been unable to find the solution

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.