I have a datagridview and I already put 3 columns in there (via design), but when I run this code, it adds another 3 columns and the data loads in those newly created ones. How can it just load the data from the columns that I made?
EDIT: 1st and 2nd Column is textbox, and 3rd is combobox.
the code is in form load:
Dim sqlDataAdapter As New MySqlDataAdapter
Dim dt As New DataTable
Dim bSource As New BindingSource
Try
sqlconn.Open()
Dim query As String
query = "SELECT * FROM tbl_subject ORDER BY yearlevel, code"
sqlcommand = New MySqlCommand(query, sqlconn)
sqlDataAdapter.SelectCommand = sqlcommand
sqlDataAdapter.Fill(dt)
bSource.DataSource = dt
datagrid_Subject.DataSource = bSource
sqlDataAdapter.Update(dt)
sqlconn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
sqlconn.Dispose()
End Try