c# DataSet更新到 Access INSERT INTO 语句的语法错误
publicvoidOperateLog(stringoperate){OleDbDataAdapterda=newOleDbDataAdapter(@"select*f...
public void OperateLog(string operate)
{
OleDbDataAdapter da = new OleDbDataAdapter(@"select * from OperateLog", database);
DataSet ds = new DataSet();
da.Fill(ds);
OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
da.UpdateCommand = cb.GetUpdateCommand();
DataRow drx = ds.Tables[0].NewRow();
drx["USER"] = userName;
drx["Operation"] = operate;
drx["Operate_Date"] = DateTime.Now.ToString("HH:mm:ss");
if(ds.Tables[0].Rows.Count <50)
{
ds.Tables[0].Rows.Add(drx);
da.Update(ds);
}
else if (ds.Tables[0].Rows.Count >= 50)
{
ds.Tables[0].Rows.RemoveAt(0);
}
} 展开
{
OleDbDataAdapter da = new OleDbDataAdapter(@"select * from OperateLog", database);
DataSet ds = new DataSet();
da.Fill(ds);
OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
da.UpdateCommand = cb.GetUpdateCommand();
DataRow drx = ds.Tables[0].NewRow();
drx["USER"] = userName;
drx["Operation"] = operate;
drx["Operate_Date"] = DateTime.Now.ToString("HH:mm:ss");
if(ds.Tables[0].Rows.Count <50)
{
ds.Tables[0].Rows.Add(drx);
da.Update(ds);
}
else if (ds.Tables[0].Rows.Count >= 50)
{
ds.Tables[0].Rows.RemoveAt(0);
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询