日期:2014-05-18 浏览次数:21121 次
public static bool updateGridView(DataGridView dgv)
{
OleDbConnection con = GreatConn();
OleDbDataAdapter oda = new OleDbDataAdapter("select * from employee",con );
try
{
if (oda != null)
{
DataTable dt = new DataTable();
oda.Fill(dt);
dgv.DataSource = dt;
}
if (oda != null)
{
OleDbCommandBuilder cmdbuilder = new OleDbCommandBuilder(oda);
OleDbCommand cmd = cmdbuilder.GetUpdateCommand();
oda.UpdateCommand = cmd;
oda.Update((DataTable)dgv.DataSource);
}
return true;
}
catch
{
return false;
}
}