用ado增删改数据表你试试这样做,引用ado Dim Con As ADODB.Connection Dim rs As ADODB.Recordset Set Con = New ADODB.Connection strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\计划管理系统.mdb;Persist Security Info=False" Con.Open strCon Set rs = New ADODB.Recordset '添加记录 strsql="select * from table" rs.Open strsql, Con, adOpenKeyset, adLockOptimistic rs.addnew rs!字段1=text1.text rs!字段2=text2.text ........ rs.update rs.close set rs=nothing '修改记录 strsql="select * from table where id=1" rs.Open strsql, Con, adOpenKeyset, adLockOptimistic rs!字段1=text1.text rs!字段2=text2.text ........ rs.update rs.close set rs=nothing
'删除记录 strsql="delete from table where id=1" rs.Open strsql, Con, adOpenKeyset, adLockOptimistic
就保存了
rs.UpdateBatch
执行更新操作必须要有rs.update,否则不能进行对数据的写入~
先写要操作的对象,最后要记得用rs.update!
Dim Con As ADODB.Connection
Dim rs As ADODB.Recordset
Set Con = New ADODB.Connection
strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\计划管理系统.mdb;Persist Security Info=False"
Con.Open strCon
Set rs = New ADODB.Recordset
'添加记录
strsql="select * from table"
rs.Open strsql, Con, adOpenKeyset, adLockOptimistic
rs.addnew
rs!字段1=text1.text
rs!字段2=text2.text
........
rs.update
rs.close
set rs=nothing
'修改记录
strsql="select * from table where id=1"
rs.Open strsql, Con, adOpenKeyset, adLockOptimistic
rs!字段1=text1.text
rs!字段2=text2.text
........
rs.update
rs.close
set rs=nothing
'删除记录
strsql="delete from table where id=1"
rs.Open strsql, Con, adOpenKeyset, adLockOptimistic
.
.
recordset.update