I'm new at coding and I need help for a school project. I want to update a database using MySQL but I can't find out how to get the update working. I have googled a bit but I haven't been able to find a solution so I figured I'd ask the question on this site.
I have successfully made a connection to the database and show the contents in a data grid. The connection has a name: "conn". If anyone knows a way on how I can get the update to work I'd be happy to hear from you!
This is my XAML.CS code:
public void Click_btnBewerk(object sender, RoutedEventArgs e)
{
string vzitter2 = txtVZitter.Text;
string info2 = txtInfo.Text;
string zetels2 = txtZetels.Text;
string stroming2 = txtStroming.Text;
string partij = cmPartijen.Text;
conn.Updateinfo();
}
This is my DBconn code:
public DataView Updateinfo()
{
conn.Open();
MySqlCommand command = conn.CreateCommand();
command.CommandText = "UPDATE partijen SET fvzitter='vzitter2', info='info2', zetels='zetels2', stroming='stroming2' WHERE partij='partij'";
MySqlDataReader reader = command.ExecuteReader();
DataTable dtData = new DataTable();
dtData.Load(reader);
conn.Close();
return dtData.DefaultView;
}