I have a datagridview bound to a datasouce, bound to a datatable. I want to create a button that when I click it, the database will be updated with the new parameters in the datagridview. I've read some stuff about TableAdapter but I cant really find some good examples and explanations.
So if someone can give some information about tableadapter, it will help me a lot. Also, if you think that you have a better solution for me regarding update the database, i'll be glad to know about that.
EDIT: ok so i'm trying to use the mysqlcommandbuilder. My code now looks like this:
MySqlDataAdapter da = new MySqlDataAdapter();
da.SelectCommand = new MySqlCommand("SELECT * from setups", sql_Class.myConnection);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
cb.GetUpdateCommand();
da.Update(dt);
so now my error is in the da.Update(dt) and it says: "input string was not in the correct format". I've created a loop that runs on all the parameters in the sql query and all the parameters values are null.
for (int i = 0; i <= cb.GetUpdateCommand().Parameters.Count - 1; i++)
{
Console.WriteLine(cb.GetUpdateCommand().Parameters[i].ParameterName + " " + cb.GetUpdateCommand().Parameters[i].Value);
}
I have values in the datatable, i've double checked it, but someone the parameters are null. Any ideas why?