【发布时间】:2014-09-15 04:11:05
【问题描述】:
private void btnUpdate_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\ALNETTE\Desktop\New folder\AccessDatabase.accdb");
string Db = "Select * from StudentInfo";
OleDbCommand cmd = new OleDbCommand(Db, con);
try
{
con.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Update");
con.Close();
}
catch (Exception)
{
MessageBox.Show("error");
}
}
我有这个更新代码,但是当我更新它时,它只更新 datagridview 而不是我的数据库。我应该怎么做才能在数据库中更新它?
【问题讨论】:
标签: c# database ms-access oledb