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 8182389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:50:54+00:00 2026-06-07T00:50:54+00:00

i am adding , deleting and updating data to database in Winforms. i have

  • 0

i am adding , deleting and updating data to database in Winforms. i have gridview on all add,delete and update forms.
After deleting records on clicking “delete” button deleted record should removed instantly from dataGridView.

////Please note that DATABIND is giving error i.e. using or assembly reference missing.

Code Behind:

    private void btnDelete_Click(object sender, EventArgs e)
    {

        if (txtIDD.Text == "")
        {
            MessageBox.Show("Please fill ID no. of record to Delete", "Important Message");

        }
        else
        {
            try
            {
                OleDbCommand Cmd = new OleDbCommand();
                Cmd.Connection = conn;
                conn.Open();
                Cmd.CommandText = "DELETE FROM AddressBook WHERE ID="+txtIDD.Text;
                Cmd.CommandType = CommandType.Text;
                Cmd.ExecuteNonQuery();
                Cmd.Connection.Close();
                conn.Close();
                dataGridView3.Update();
                MessageBox.Show("Delete Succesfull");
            }
            catch (System.Exception err)
            {
                  dataGridView3.DataSource = dt;
                  dataGridView3.DataBind();
                  dataGridView3.Update();

                this.label27.Visible = true;
                this.label27.Text = err.Message.ToString();
            }
        }

    }
  • 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-07T00:50:56+00:00Added an answer on June 7, 2026 at 12:50 am

    Bind the grid again to fetch values form database after add, update and delete etc.

    private void btnDelete_Click(object sender, EventArgs e)
    {
    
        if (txtIDD.Text == "")
        {
            MessageBox.Show("Please fill ID no. of record to Delete", "Important Message");
    
        }
        else
        {
            try
            {
                OleDbCommand Cmd = new OleDbCommand();
                Cmd.Connection = conn;
                conn.Open();
                Cmd.CommandText = "DELETE FROM AddressBook WHERE ID="+txtIDD.Text;
                Cmd.CommandType = CommandType.Text;
                Cmd.ExecuteNonQuery();
                Cmd.Connection.Close();
                conn.Close();                
    
                **//Call a method that binds the grid or get DataTable from database and bind it like this**
                 dataGridView3.DataSource = dt;               
                dataGridView3.Update();
    
                MessageBox.Show("Delete Succesfull");
            }
            catch (System.Exception err)
            {
                this.label27.Visible = true;
                this.label27.Text = err.Message.ToString();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know what the esiest way to update the entity model after adding/deleting
What is the need of Collection framework in Java since all the data operations(sorting/adding/deleting)
Say, you are submitting a form, which affects your database (adding records/ deleting them/
How to refresh an Android ListView after adding/deleting dynamic data?
I have a mysql database that I want to add the functionality of adding
I have a table mapped in Entity Framework which works great adding/updating and deleting
Which XML structure allows me faster adding,deleting,updating of a node? My assumption is the
I have two aspx files for adding/deleting products to/from a sale. islemler.aspx SatisTedarik.aspx I
I've the following BLL class, which provides tools for adding, updating and deleting elements
I am planning to audit/log few events on my Web site (like adding/updating/deleting few

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.