Yes, I know there are other posts on this but I can't understand what to change or where to make the solutions fit my code.
Error:
Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound.
Code:
Public Sub dsLoadEvents()
dsConnectionE = New OleDbConnection
dsConnectionE.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data source=DataSourceDB.accdb"
dsDataAdapterE = New OleDbDataAdapter
dsDataAdapterE.SelectCommand = New OleDbCommand
dsDataAdapterE.SelectCommand.Connection = dsConnectionE
dsDataAdapterE.SelectCommand.CommandText = "SELECT * FROM Event"
dsDataAdapterE.SelectCommand.CommandType = CommandType.Text
dsConnectionE.Open()
dsDataSetE = New DataSet
dsDataAdapterE.Fill(dsDataSetE, "dataSetEvents")
dsConnectionE.Close()
Form3.dgdEvents.AutoGenerateColumns = True
Form3.dgdEvents.DataSource = dsDataSetE
Form3.dgdEvents.DataMember = "dataSetEvents"
End Sub
That is where the Events are loaded when the program is first opened. I am working on adding things to the database however I tried using the following code to add it to the DataGridView
but it gave me the error above.
Form3.dgdMembers.Rows.Add(New String() {Form3.tbceid.Text, Form3.tbfn.Text, Form3.dtpesd.Value, Form3.dtpdob.Value, Form3.tbal2.Text, Form3.tbal1.Text, Form3.tbpgfn.Text, Form3.tbpgsn.Text, Form3.tbcpp.Text, Form3.tbelid.Text})