Office中国论坛/Access中国论坛
标题:
请教如何把ado代码改为dao代码?
[打印本页]
作者:
franklin2k
时间:
2006-11-1 16:25
标题:
请教如何把ado代码改为dao代码?
ado代码如下:
Dim Rst As New ADODB.Recordset
Dim Conn As New ADODB.Connection
Set Conn = CurrentProject.Connection
Rst.Open "select 字段1,字段2,... from 表1 where ....", Conn, adOpenDynamic, adLockOptimistic
If Rst.Fields("字段1") = "1" Then
Conn.Execute "uptate 表2 set 表2.字段a='yes'"
Else
Conn.Execute "uptate 表2 set 表2.字段b=100"
End If
Set Rst = Nothing
Set Conn = Nothing
若想用dao代码应如何写?谢谢
作者:
情比金坚
时间:
2006-11-2 06:07
Dim Rst As DAO.Recordset
Set Rst = CurrentDb.OpenRecordset("select 字段1,字段2,... from 表1 where ....")
If Rst("字段1") = "1" Then
DoCmd.RunSQL "uptate 表2 set 表2.字段a='yes'"
Else
DoCmd.RunSQL "uptate 表2 set 表2.字段b=100"
End If
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3