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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:16:59+00:00 2026-05-23T21:16:59+00:00

my last question was closed because it wasn’t clear, so I’ll try again because

  • 0

my last question was closed because it wasn’t clear, so I’ll try again because I really need help for this…

I am using Visual Studio 2010 with an OLEDB connection. Right now I’m developing a windows form. I noticed that a datagridview allows you to have an edit/add/delete mode, so I want to be able to use it.

What I want to do is have the cellcontentchanged event used to edit my database. When I change the content and leave, it’ll ask me if I want to edit this cell. If I say yes, then that cell will be changed.

I made sure ReadOnly = false and enabled = true. Before, what from what I read, I would just do something like this:

adapter.Update(dataset); 

or something like this. however, this does not save the changes of my databse. I’m also not sure how to edit programmatically. I’m also not sure if I should have an OLEDB update command or not. If anything is not clear, please reply and I would be glad to clarify. Thank you!

edit: sorry if its still hard to understand!

here is some code…

    private void dgv_DataLookup_CellValueChanged(object sender, DataGridViewCellEventArgs e)
    {

        DialogResult dr;
        dr = MessageBox.Show("Are you sure you want to edit this field?", "Edit Cell", MessageBoxButtons.YesNo);

        if (dr == DialogResult.Yes)
        {
            //update the table in my database
        }
    }

this is not a lot yet, but hopefully you can try to see what i’m trying to do

edit again: This is all the relevant code for this part (this is the code that displays the datagridview that I want to edit )

    OleDbConnection cs;
    OleDbDataAdapter da = new OleDbDataAdapter();

    DataSet dsB = new DataSet();



    //If clicked search button
        else if (combo_View.Text == "Orders")
        {

            da.SelectCommand = new OleDbCommand("SELECT * FROM TestQuery WHERE (VendorName = @VendorName OR @VendorName = '') AND (CustomerName = @CustomerName OR @CustomerName = '')  AND ((@From IS NULL AND @To IS NULL) OR orderDate BETWEEN @From AND @To) AND (ItemNum = @ItemNum OR @ItemNum = '') AND (PO = @PO OR @PO = '') ORDER BY CustomerName", cs);

            da.SelectCommand.Parameters.Add("@VendorName", OleDbType.VarChar).Value = combo_VendorView.Text.ToString();
            da.SelectCommand.Parameters.Add("@CustomerName", OleDbType.VarChar).Value = combo_CustomerView.Text.ToString();

            if (!chk_viewAllDates.Checked)
            {
                da.SelectCommand.Parameters.Add("@From", OleDbType.Date).Value = "#" + tp_viewFrom.Value.Date.ToString("M/d/yyyy") + "#";
                da.SelectCommand.Parameters.Add("@To", OleDbType.Date).Value = "#" + tp_viewTo.Value.Date.ToString("M/d/yyyy") + "#";
            }

            else
            {
                da.SelectCommand.Parameters.Add("@From", OleDbType.Date).Value = DBNull.Value;
                da.SelectCommand.Parameters.Add("@To", OleDbType.Date).Value = DBNull.Value;
            }

            da.SelectCommand.Parameters.Add("@PO", OleDbType.VarChar).Value = txt_POLookup.Text.ToString();
            da.SelectCommand.Parameters.Add("@ItemNum", OleDbType.VarChar).Value = combo_ItemNumLookup.Text.ToString();

            dsB.Clear();
            da.Fill(dsB);
            dgv_DataLookup.DataSource = dsB.Tables[0];

        }

please let me know if you need more code. any help is appreciated 🙂

  • 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-05-23T21:17:00+00:00Added an answer on May 23, 2026 at 9:17 pm

    Fixed this myself. Just use owningcolumn owningrow to get values i needed. Thanks

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

Sidebar

Related Questions

Due to a problem posting, my last question (duplicate of this) was closed. Background
I am asking this here because I think my last question was more than
My last question was somewhat narrower than this one. I am interested to know
Following on from my last question What is a Stub , I would really
Following from my last question which @Jon Skeet gave me a lot of help
This is a followup to my last question . I now have a byte[]
As my last question was closed for being too vague - here it is
This question is long winded because I have been updating the question over a
I know this is a dumb question, but its really bugging me. Take the
This is similar to my last question. I'm making a simple tcp/ip chat program

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.