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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:47:03+00:00 2026-05-29T19:47:03+00:00

I work with windows forms and on the form I have a DataGridView. This

  • 0

I work with windows forms and on the form I have a DataGridView. This gridView I fill with a DataTable dt. The dt I fill with OdbcDataAdapter. For save the changes I use adaper.Update(dt) on Event Handler gridView_RowLeave. The problem is that dt doesn’t have last changes of gridView. For exemple if I modify some data in one row or add a new row with data when I leave that row the method dt.GetChages() return false and I must leave more that 1 row for dt.GetChanges() return true. Where can be the problem? Here is my code:

Private Sub FillGridview()
  Dim adapter As OdbcDataAdapter

  Dim sCommand As New OdbcCommand("Select * from SPEAKERS", con)
  adapter = New OdbcDataAdapter(sCommand)
  adapter.UpdateCommand = UpdateCommand() 'return a query for Update 
  adapter.InsertCommand = InsertCommand() 'return a query for Insert but without ID
  adapter.DeleteCommand = DeleteCommand()

  Try
    adapter.Fill(dt)
  Catch ex As Exception
    MsgBox(ex.Message)
  End Try
  gridView.DataSource = dt
End Sub

Private Sub gridView_RowLeave(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles gridView.RowLeave
gridView.EndEdit()
If dt.GetChanges() IsNot Nothing Then
  Try
    Dim res As Integer = adapter.Update(dt)
  Catch ex As Exception
    MsgBox(ex.Message)
    dt.Clear()
    adapter.Fill(dt)
  End Try
  If Not dt.HasErrors Then
    dt.AcceptChanges()
  End If
  gridView.Refresh()
End If
End Sub

Does anyone have any idea why dt don’t have last changes?

Thanks in advance!

  • 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-29T19:47:05+00:00Added an answer on May 29, 2026 at 7:47 pm

    Try to put a bindingSource component to handle data and do not link the grid directly to data

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

Sidebar

Related Questions

I have 2 Windows Forms. In first, the main window form, has multiline textbox
I have a Windows forms app in .Net 4.0. I work in C#. I
I have a scenario. (Windows Forms, C#, .NET) There is a main form which
I have setup a windows forms project to use localization so that it will
I am developing a windows form application in C#. I have a datagridview on
I have a windows forms project. It has a main form derived from System::Windows::Forms::Form
I have a form with label that is updating by System.Windows.Forms.Timer control every 2
I'm trying to get this simple program to work on windows, but it crashes:
I have a Windows Form that displays several DataGridViews in the following layout: (No
Im using c# .net windows form application. I have created a database which has

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.