Refreshing Datagridview from form 1 after closing form 2

xerexie

Member
Joined
Apr 5, 2011
Messages
5
Programming Experience
Beginner
Hi. I have two forms. In form 1 is where my datagridview is. When i click a button, it opens up form2 which has textboxes where I input data. What I wanna do is after closing form 2, changes should reflect on the datagridview on form 1.

Below is my code for filling my datagridview:
VB.NET:
Public Sub getClassList()
        Dim query As String = "select p.PersonID as ID, p.FirstName, p.Lastname, p.StudentSection, p.StudentYear, sc.Prelim, sc.Midterm, sc.Prefinal, sc.Final from person p join StudentClass sc on sc.StudentID=p.PersonID where sc.ClassID='" & classid & "'"
        Dim table As New DataTable
        Dim adapter As New MySqlDataAdapter
        Dim command As New MySqlCommand


        With command
            .CommandText = query
            .Connection = SQLConnection
        End With


        With adapter
            .SelectCommand = command
            .Fill(table)
        End With


        DataGridView2.DataSource = table


    End Sub
 
Back
Top