你好 如何在c#,winform程序中 获取access数据库中最后一条记录,并使用该记录的字段值
我写的一段添加记录的代码:stringstrConnect=@"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=e:\DB\db1...
我写的一段添加记录的代码:
string strConnect =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\DB\db1.mdb ";
OleDbConnection aConnection = new OleDbConnection(strConnect);
aConnection.Open();
OleDbDataAdapter da = new OleDbDataAdapter(@"select * from table1", aConnection);
DataSet ds = new DataSet();
da.Fill(ds);
OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
da.UpdateCommand = cb.GetUpdateCommand();
DataRow newData = ds.Tables[0].NewRow();
newData["col1"] = tb1.Text;
newData["col2"] = tb2.Text;
ds.Tables[0].Rows.Add(newData);
da.Update(ds); 展开
string strConnect =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\DB\db1.mdb ";
OleDbConnection aConnection = new OleDbConnection(strConnect);
aConnection.Open();
OleDbDataAdapter da = new OleDbDataAdapter(@"select * from table1", aConnection);
DataSet ds = new DataSet();
da.Fill(ds);
OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
da.UpdateCommand = cb.GetUpdateCommand();
DataRow newData = ds.Tables[0].NewRow();
newData["col1"] = tb1.Text;
newData["col2"] = tb2.Text;
ds.Tables[0].Rows.Add(newData);
da.Update(ds); 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询