Solved

VB.net Windows Form Refreshing data in a DataGridView

Posted on 2011-09-14
2
280 Views
Last Modified: 2012-05-12
Hi

I am running the following procedire after I make cahnges to my database
to refresh the DataGridView but it isn't refreshing
I use code
 Call Fill_Supplier_DGV()
            Me.Supplier_DataGridView.Refresh()
but even the refresh doesn't work. Should I delete everything first? How would I do this?
Sub Fill_Supplier_DGV()
        Try


            Dim sSQL As String

            sSQL = "SELECT * FROM Suppliers"

            Dim connection As New OleDbConnection(ConnectionString)
            Dim dataadapter As New OleDbDataAdapter(sSQL, connection)
            Dim ds As New DataSet()
            connection.Open()
            dataadapter.Fill(ds, "Suppliers_table")
            connection.Close()
            Me.Supplier_DataGridView.DataSource = ds
            Me.Supplier_DataGridView.DataMember = "Suppliers_table"

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

Open in new window

0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 36534901
You need to empty the datagrid before resetting the DataSource. Set the DataSource to Nothing before reassigning a new value to it:
Me.Supplier_DataGridView.DataSource = Nothing
Me.Supplier_DataGridView.DataSource = ds

Open in new window

0
 

Author Closing Comment

by:Murray Brown
ID: 36535125
Great. Thanks very much
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question