首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

使用DataTable的Clear方法,为什么Access数据库中原来的记录没有被清除?解决思路

2012-04-07 
使用DataTable的Clear方法,为什么Access数据库中原来的记录没有被清除?我的代码如下:DimpErrorTableAsData

使用DataTable的Clear方法,为什么Access数据库中原来的记录没有被清除?
我的代码如下:
Dim   pErrorTable   As   DataTable   '得到表。经过测试,已经被正确得到
pErrorTable.Clear() '清除原来的记录
      Dim   pErrorRow   As   DataRow
                                pErrorRow   =   pErrorTable.NewRow
                                pErrorRow( "表名称 ")   =   g_pipeTypeCol(i).tableName
                                pErrorRow( "描述 ")   =   "不存在 "
                                pErrorTable.Rows.Add(pErrorRow)

Dim   CB   As   New   OleDb.OleDbCommandBuilder(pAdapter)   '更新数据库
                pAdapter.Update(pDataSet.GetChanges)
                pDataSet.AcceptChanges()

经过上面代码操作后,新的记录被加入到Access数据库中,但原来的记录却没有被清除。为什么?

[解决办法]
pErrorTable.Clear() '清除原来的记录
'后面没有用

pAdapter.Update(pDataSet.GetChanges)
pDataSet.AcceptChanges()

热点排行