问题描述
- 如何通过一个button来将datagridview中的内容更新到数据库中
-
我通过datatable来填充数据 但如何将datagridview中的更改后的数据更新到数据库中就不会了。。。private void Form2_Load(object sender, EventArgs e)
{dataGridView1.AllowUserToAddRows = false; OleDbConnection conn = new OleDbConnection(); conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;;Data Source=g:\C#\windows程序\MISapp\MISapp\em.accdb;"; try { OleDbDataAdapter da = new OleDbDataAdapter(@"select * from employee", conn); conn.Open(); DataTable table = new DataTable(); da.Fill(table); dataGridView1.DataSource = table; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { if (conn.State == ConnectionState.Open) conn.Close(); } dataGridView1.UnDo_ReDoInitialize(); }
时间: 2024-12-22 00:22:19