Subject: RE: SQL
rb,
the agent works fine if i add a Datasource on the client’s side and run it manually. however, my agent runs on a scheduled basis, i already added a server datasource but still the agent cannot connect to the external dbase.
below is my code:
Uselsx “*LSXODBC”
Sub Initialize
Dim con As New ODBCConnection
Dim qry As New ODBCQuery
Dim result As New ODBCResultSet
Dim msg As String
Dim doc As notesdocument
Dim vdoc As notesdocument
Dim s As NotesSession
Dim db As NotesDatabase
Dim dcol As notesdocumentcollection
Dim ws As New notesuiworkspace
Dim dateTime As New NotesDateTime(“01/01/2000”)
Dim RTI
Set S = New NotesSession
Set db=s.Currentdatabase
Set qry.Connection = con
Set result.Query = qry
con.ConnectTo(“SQL Notes”),(“username”),(“password”)
qry.SQL = “SELECT * FROM students”
result.Execute
Messagebox result.NumColumns
msg = “Student names:” & Chr(10)
Do
result.NextRow
For i = 1 To result.NumColumns
msg = msg & " " & result.GetValue(i) If i=1 Then
abc = result.GetValue(i)
Else
def = result.GetValue(i)
End If
Next
Set MDoc = New NotesDocument(Db)
MDoc.Form = "test"
MDoc.studnumber = abc
MDoc.emp_number = def
Call MDoc.Save (False, False)
Loop Until result.IsEndOfData
Messagebox msg,, "Student data"
result.Close(DB_CLOSE)
con.Disconnect
End Sub