Iv looked around, and found many solutions, but they either dont make enough sense to apply to my specific issue, or they dont work.
Heres what I have:
1 form that holds a datagridview, that is supposto contain a bunch of usernames and passwords.
This form is never seen by the user.
Another form - in which the user sees, that asks them for a username and password, then a "Log In" button.
Upon pressing the button, the program runs through every item on the datagridview until it finds the exact username you typed in, if it finds it, it sees if the password attached to that username matches, if it cannot find the username, or the password doesnt match, it returns a error to the user saying "the username or password you entered was not found" (depending on which field as wrong)
That all works fine.
But... For whatever reason I cant access this database, unless I access it programmically...
So, heres my problem:
I added a new row to the datagridview, before it looks through it (because for whatever reason it would never save the items, so its alaways -1 rows in the database), then I rigged it for that first field (Username field) to be "Bob" for example - then I had it check, if the username they entered (Again, Bob for example), is the same as the name in the database, then say your logged in, otherwise, say "failed".
What it does is, its crashing saying the following error:
Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound.
So, my question:
How do I either 1.
Unbind this data-bound control?
Edit the rows without alot of complicated code?
Here is the code I have now:
Form2.DataGridView1.Rows(0).Cells(0).Value = "Bob"
If Textbox1.Text = Form2.DataGridView1.Rows(0).Cells(0).Value Then
Could anyone give me some sample code aswell? That would be greatly appreciated.
Also, the datagridview is never edited during runtime, and I cant manually add items to it in the design view.