自己解决问题。
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim con As New ODBCConnection
Dim qry As New ODBCQuery
Dim result As New ODBCResultSet
Dim Sview As NotesView
Dim Sdoc As notesDocument
Dim j As Integer
Dim k As Integer
k=0
Set Sview = db.GetView("EmployeeInfo1")
Set Sdoc = view.GetDocumentByKey("EmployeeId" )
ItemValue= Ubound(Bdoc.Item)-Lbound(Bdoc.Item)
For j=0 To ItemValue
'get the value of employeeId from the existed document
EmployeeId= Sdoc.GetItemValue(EmployeeId)
'look up this employee's information in the SQL database
Set db = session.CurrentDatabase
If Not con.ConnectTo("NotesTest","hr","hr") Then
Messagebox "Could not connect to NotesTest",, _
"Error connecting"
Exit Sub
End If
Set qry.Connection = con
Set result.Query = qry
qry.SQL = "SELECT employee_id FROM NotesTestTable where employee_id = EmployeeId ORDER BY employee_id"
result.Execute
If result.IsValueNull(employee_id) Then
'delete the employee's document in Notes.
Bdoc.remove(True)
k=k+1
'if k >= 30, then send a reminding email to system admin
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim con As New ODBCConnection
Dim qry As New ODBCQuery
Dim result As New ODBCResultSet
Dim Sview As NotesView
Dim nextdoc As notesDocument
Dim j As Integer
Dim k As Integer
k=0
Set db = session.CurrentDatabase
Set Sview = db.GetView("EmployeeInfo1")
If Not con.ConnectTo("NotesTest","hr","hr") Then
Messagebox "Could not connect to NotesTest",, _
"Error connecting"
Exit Sub
End If
Set doc = Sview.GetFirstDocument
While Not (doc Is Nothing )
Set nextdoc= Sview.getnextdocument(doc)
EmployeeId = doc.EmployeeId(0)
'look up this employee's information in the SQL database
Set qry.Connection = con
Set result.Query = qry
qry.SQL = "SELECT * FROM NotesTestTable where employee_id ='"& EmployeeId & " ' "
result.Execute
testValue= result.GetValue(1)
If (testValue= False) And (doc.form(0) = "Employee Information") Then
'if this employee's information does not exist, then delete the employee's document in Notes.
Call doc.Remove(True)
k=k+1
'if k >= 30, then send a reminding email to system admin