问题描述
为什么不更新Access DB?
字符串Connstr ="Provider = Microsoft.ACE.OLEDB.12.0; Data Source = C:\\ SLTier \\ database31.accdb;";
字符串strSQL ="SELECT * FROM transaction2";
OleDbConnection conn =新的OleDbConnection(Connstr);
OleDbDataAdapter tranAdapter =新的OleDbDataAdapter();
tranAdapter.SelectCommand =新的OleDbCommand(strSQL,conn);
DataSet tranData =新的DataSet();
tranAdapter.Fill(tranData,"transaction2");
DataTable tranTable = tranData.Tables ["transaction2"];
DataRow []找到的行;
foundrows = tranTable.Select(flSL,srtSL);
for(int i = 0; i< foundrows.Length; i ++)
{
//foundrows [i] ["prodatetime"] = DateTime.Now.ToLocalTime();
Console.WriteLine(处理之前:" + foundrows [i] [已处理"] .ToString());
字符串errstr = foundrows [i] .RowState.ToString();
Console.WriteLine("New Rows:" + errstr);
foundrows [i] ["processed"] = true;
foundrows [i] ["prodatetime"] = DateTime.Now.ToLocalTime().ToString();
errstr = foundrows [i] .RowState.ToString();
Console.WriteLine(时间后处理:" + errstr);
Console.WriteLine(后处理:" + foundrows [i] [已处理"] .ToString());
Console.WriteLine(之后的常驻进程:" + foundrows [i] ["resident"].ToString());
Console.WriteLine("Time after time:" + foundrows [i] ["prodatetime"].ToString());
foundrows [i] .AcceptChanges();
预先感谢您的协助!
干杯
RMR
Why isnt the Access DB not being Updated?
string Connstr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\SLTier\\database31.accdb;";
string strSQL = "SELECT * FROM transaction2";
OleDbConnection conn = new OleDbConnection(Connstr);
OleDbDataAdapter tranAdapter= new OleDbDataAdapter();
tranAdapter.SelectCommand= new OleDbCommand(strSQL,conn);
DataSet tranData = new DataSet();
tranAdapter.Fill(tranData,"transaction2");
DataTable tranTable = tranData.Tables["transaction2"];
DataRow[] foundrows;
foundrows = tranTable.Select(flSL, srtSL);
for (int i = 0; i < foundrows.Length; i++)
{
// foundrows[i]["prodatetime"] = DateTime.Now.ToLocalTime();
Console.WriteLine("Process Before: " + foundrows[i]["processed"].ToString());
String errstr = foundrows[i].RowState.ToString();
Console.WriteLine("New Rows : " + errstr);
foundrows[i]["processed"] = true;
foundrows[i]["prodatetime"] = DateTime.Now.ToLocalTime().ToString();
errstr = foundrows[i].RowState.ToString();
Console.WriteLine("Process after Time: " + errstr);
Console.WriteLine("Process after: " + foundrows[i]["processed"].ToString());
Console.WriteLine("Resident Process after: " + foundrows[i]["resident"].ToString());
Console.WriteLine("Process after Time: " + foundrows[i]["prodatetime"].ToString());
foundrows[i].AcceptChanges();
Thank you in advance for your assistance!
Cheers
RMR
推荐答案
这篇关于C#Access DB更新行/数据源,AcceptChange不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!