I've been trying to figure out how to clear and redraw the DataGridView. But so far I have been getting the same results where the data just keeps on writing and writing itself on refresh, resulting on redundant records.
Here is my code:
DataGridView1.DataSource = Nothing
DataGridView1.DataMember = Nothing
DataGridView1.Columns.Clear()
DataGridView1.Rows.Clear()
SQLSTR = "SELECT * FROM '" & ClassIntl & "'"
DBConn()
SQLDA.Fill(DS, "Grades")
SQLCONN.Close()
DataGridView1.DataSource = DS
DataGridView1.DataMember = "Grades"
With DataGridView1
.RowHeadersVisible = False
.Columns(0).HeaderCell.Value = "Student ID"
.Columns(1).HeaderCell.Value = "First Name"
.Columns(2).HeaderCell.Value = "Last Name"
.Columns(3).HeaderCell.Value = "Quiz 1"
.Columns(4).HeaderCell.Value = "Quiz 2"
.Columns(5).HeaderCell.Value = "Quiz 3"
.Columns(6).HeaderCell.Value = "Quiz 4"
.Columns(7).HeaderCell.Value = "Quiz 5"
.Columns(8).HeaderCell.Value = "Quiz 6"
.Columns(9).HeaderCell.Value = "CS Prelim"
.Columns(10).HeaderCell.Value = "CS Midterm"
.Columns(11).HeaderCell.Value = "CS Finals"
.Columns(12).HeaderCell.Value = "Attend Prelim"
.Columns(13).HeaderCell.Value = "Attend Midterm"
.Columns(14).HeaderCell.Value = "Attend Finals"
.Columns(15).HeaderCell.Value = "Exam Prelim"
.Columns(16).HeaderCell.Value = "Exam Midterm"
.Columns(17).HeaderCell.Value = "Exam Finals"
.Columns(18).HeaderCell.Value = "Total Prelim"
.Columns(19).HeaderCell.Value = "Total Midterm"
.Columns(20).HeaderCell.Value = "Total Finals"
.Columns(21).HeaderCell.Value = "Final Grade"
End With
Suggestions would be great, thank you!
Aucun commentaire:
Enregistrer un commentaire