Skip to main content

 none
DataGridView Update Command RRS feed

  • Question

  • Hi,

    I want to use a Datagridview to Filter Record and Update/Edit Record , without writing Update SQL. Minimum or no code.

    I want to save this to Database.

    Regards.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help , or you may vote-up a helpful post

    • Moved by Hart Wang Friday, March 30, 2018 5:08 AM
    Thursday, March 29, 2018 11:54 PM

Answers

  • Hi,

    If you do not want to use SQL statement, try to use binding source instead:

    You can bind a data source for datatgridview through the small arrow in the upper right corner:

    Then filter and update the record with:

        //Filter
        private void button5_Click(object sender, EventArgs e)
        {
            table1BindingSource1.Filter = "Name='Kobe'";
        }
    
        //update
        private void button6_Click(object sender, EventArgs e)
        {
            table1BindingSource1.ResetItem(0);
            table1TableAdapter1.Update(database100DataSet1.Table1);
        }

    Regards,

    Frankie


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by murtazagandhi Friday, March 30, 2018 2:51 PM
    Friday, March 30, 2018 7:00 AM
    Moderator

All replies

  • Hi,

    Thank you for posting here.

    Since your issue is related to Datagridview, I will move the case to winform forum.

    Best Regards,

    Hart


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 30, 2018 4:46 AM
  • Hi,

    If you do not want to use SQL statement, try to use binding source instead:

    You can bind a data source for datatgridview through the small arrow in the upper right corner:

    Then filter and update the record with:

        //Filter
        private void button5_Click(object sender, EventArgs e)
        {
            table1BindingSource1.Filter = "Name='Kobe'";
        }
    
        //update
        private void button6_Click(object sender, EventArgs e)
        {
            table1BindingSource1.ResetItem(0);
            table1TableAdapter1.Update(database100DataSet1.Table1);
        }

    Regards,

    Frankie


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by murtazagandhi Friday, March 30, 2018 2:51 PM
    Friday, March 30, 2018 7:00 AM
    Moderator
  • Hi,

    The same this was not working.

    I configured with new dataset, using the wizard. Then it worked.

    I have Community Edition 2017 VS

    Regards.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help , or you may vote-up a helpful post


    • Edited by murtazagandhi Friday, March 30, 2018 2:54 PM added text
    Friday, March 30, 2018 2:53 PM