|
原帖由 yanlj518 于 2008-5-20 11:16 发表
因为有其它作途,要用ADO,能赐教吗?
SELECT b2.ID, b2.学号, b2.姓名
FROM b2
WHERE (((b2.学号) Not In (select 学号 from b1)));
上面的语句为: B2有记录,而B1没记录, 如果一定要用ADO把上面的语句写到B1就行了
Dim Sql As String
Dim Rs As New ADODB.Recordset
Dim Rsc As New ADODB.Recordset
Dim Conn As New ADODB.Connection
Set Conn = CurrentProject.Connection
Sql = "SELECT b2.ID, b2.学号, b2.姓名 FROM b2 WHERE b2.学号 Not In (select 学号 from b1)"
Rs.Open Sql, Conn, adOpenKeyset, adLockOptimistic
Rsc.Open "select * from b1", Conn, adOpenDynamic, adLockOptimistic
Do While Not Rs.EOF
Rsc.AddNew
Rsc.Fields("学号") = Rs.Fields("学号")
Rsc.Fields("姓名") = Rs.Fields("姓名")
Rsc.Update
Rs.MoveNext
Loop
Rs.Close
Rsc.Close
Set Rs = Nothing
Set Rsc = Nothing |
|