In my application i have used DataGridView for displaying the data available in my table (SQL database).
The form containing the datagridview is accisible from the menu in MDI Form.

Problem: Every time i access the datagridview form, the same data gets appended to the old data in the datagridview hence creating multiple appearence of the same data. What i need to do in order to avoide this????


Public Class frmRecordsInDataGridvieCoding
    Dim sql As String
    Private Sub frmRecordsInDataGridvieCoding_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Conn = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\college.mdf;Integrated Security=True;User Instance=True")
        sql = ""
        sql = "SELECT formNumber,fName FROM admissionForms"
        dataAdapter = New SqlDataAdapter(sql, Conn)
        dataAdapter.Fill(dataSet, "admissionForms")
        ' Set the DataGridView properties to bind it to our data...
        DataGridView1.DataSource = dataSet
        DataGridView1.DataMember = "admissionForms"
        DataGridView1.Columns(0).HeaderText = "Form Number"
        DataGridView1.Columns(1).HeaderText = "First Name"
        End Sub
End Class

You can check out the image that i have uploaded.

You should have a .ClearBeforeFill property on your dataAdapter if it was created by the designer. If not you can call dataSet.Clear() before you call .Fill()

i did't found any method like .ClearBeforeFill() for data adapter but found .clear() method for dataset and it worked.

thank you very much