Vb.net – How to refresh datagridview after update in vb.net

datagridviewvb.netwinforms

Here is my code:

        Dim sqledit As New SqlCommand
        sqledit = New SqlCommand("UPDATE Branches SET StAddress='" + txtstaddress.Text + "',City='" + txtcity.Text + "',Province='" + txtprovince.Text + "',ContactNo='" + txtcontact.Text + "' WHERE BranchID='" + txtbranchid.Text + "'", con1)
        sqledit.ExecuteNonQuery()
        MsgBox("Branch Information Updated!", MsgBoxStyle.Information, Title:="Edit Branch Information")
        utilities.Refresh()
        Me.Close()

I can't get to update it even if I refresh it. Please help!

Best Answer

There is easy way too you can make a query by your datagridview that call all of your table content example:

SELECT {your table field}
FROM {table name}

If you execute this query after changes it will show you the new data on DGV.

Related Topic