I’m having a tough time getting an agent to connect to a MS SQL server to do some data processing. This is a scheduled agent, but it hangs when calling the con.ConnectTo(“HRTEST”…). The agent manager executive 1 will sit there with this agent trying to run indefinately; I can’t kill it except by rebooting. If the agent is run from a local client, it works fine. The DSN is setup correctly on the Domino server and can connect when doing the test in the Windows setup. I’ve never had this issue before. Right now the agent is simply coded to connect, print a confirmation message and disconnect. Any help appreciated! Code below (username and password in connect string purposely not displayed):
Sub Initialize
Dim session As New NotesSession
Dim doc As NotesDocument
Dim db As NotesDatabase
Dim con As ODBCConnection
Dim qry As ODBCQuery
Dim res As ODBCResultSet
Set db = session.CurrentDatabase
Set doc = db.CreateDocument
doc.Form = "Employees"
Set con = New ODBCConnection
Set qry = New ODBCQuery
Set res = New ODBCResultSet
Set qry.Connection = con
Set res.Query = qry
Print "Trying SQL Connection..."
If con.ConnectTo("HRTEST","****","****") Then 'HANGS HERE!
Print "Connected to SQL Server OK"
con.Disconnect
Exit Sub
qry.SQL = "SELECT * FROM EMPLOYEE"
res.Execute
Do
res.NextRow
doc.EmpName = res.GetValue("FIRSTNAME") & " " & res.GetValue("LASTNAME") & Chr(10)
doc.EmpID = res.GetValue("EMPID") & Chr(10)
doc.EmpEmail = res.GetValue("EMAIL") & Chr(10)
Loop Until res.IsEndOfData
res.Close(DB_CLOSE)
con.Disconnect
Call doc.Save(True,False)
Else
Print "Could not connect to SQL Server!"
Exit Sub
End If
End Sub