i've been working on some tool that can edit data in my mysql database everything works other than the update data say i edit the table through the program edit the name of an entry it won't update this is what i have so far if anyone could help would be greatly appreciated thanks.
private void button4_Click(object sender, EventArgs e)
{
try
{
string MyConnection2 = "datasource=localhost;port=3306;username=root;password=toor";
//Display query
string Query = "select * from truck.jobs;";
MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
// MyConn2.Open();
//For offline connection we weill use MySqlDataAdapter class.
MySqlDataAdapter MyAdapter = new MySqlDataAdapter();
MyAdapter.SelectCommand = MyCommand2;
DataTable dTable = new DataTable();
MyAdapter.Fill(dTable);
dataGridView1.DataSource = dTable; // here i have assign dTable object to the dataGridView1 object to display data.
// MyConn2.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
the current tables being used in the database are id,Name,PlayerUID,JobsCompleted,MoneyEarned,CargoWeight,DrivenDistance
i'm using a data grid to view the data in the tool
here is an image of the tool
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…