c#怎么把datatable写入mysql数据库

2024-11-15 14:53:28
推荐回答(1个)
回答(1):

                OleDbCommand cm = new OleDbCommand();
                cm.Connection = conn;
                cm.CommandText = "SELECT * FROM " + strTable;
                OleDbDataAdapter ad = new OleDbDataAdapter(cm);
                OleDbCommandBuilder build = new OleDbCommandBuilder(ad);
                int n = ad.Update(datable);
                datable.AcceptChanges();
                MessageBox.Show(string.Format("更新了{0}条记录!", n));

大概这样