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????
Code:
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")
Conn.Open()
sql = ""
sql = "SELECT formNumber,fName FROM admissionForms"
dataAdapter = New SqlDataAdapter(sql, Conn)
dataAdapter.Fill(dataSet, "admissionForms")
Conn.Close()
DataGridView1.ClearSelection()
' 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.