ODBC error 720

Hey

I´m writing a new Lotusscript agent to import customer info. from a ODBC source (Navision Attain).

I´ve got 3 other scheduled agents connecting to the same OBDC source, so all the initial code its taken from these agents.

Problem:

When running the new agent locally (during testing and debugging), everything related to establishing the connection, making a query and returning a resultset is working fine (I have a local ODBC source setup) …at least the first time I run the agent (the first time = the first time after starting the designer client).

BUT when I want to trigger a second run, I get a error 720 on the connection, with the following message text:

‘[Navision Software a/s][Navision Attain ODBC Driver]ISAM error’

…and the datasourcename property on the connection is empty…

And the only way to solve this is to restart my Notes/designer clients, and then it works fine again - but only one time.

It seems to me that I might not close the ODBC connection properly, but I´ve looked through the documentation, and can´t find what I´m missing…

Below is the main code related to the connection to ODBC:

Set con = New ODBCConnection

Set qry = New ODBCQuery

Set result = New ODBCResultSet

con.SilentMode=True

result.maxRows=0

Set qry.Connection = con

Set result.Query = qry





If 	con.ConnectTo("AttainCODBC") Then



	qry.SQL ="SELECT * from Debitor WHERE (""Udlæs til Notes""=1)"





	Do

		result.NextRow		

…code doing different kinds of document updates

…this code is executed on the first run of the agent

	Loop Until result.IsEndOfData



Else

…code executing on second, third etc. run of the agent…

	errNum = con.GetError

	errMsg	 =	con.GetExtendedErrorMessage(errNum)						

	result.Close(DB_CLOSE)

	con.Disconnect

	Set result = Nothing

	Set con = Nothing



End If





result.Close(DB_CLOSE)

con.Disconnect

Set result = Nothing

Set con = Nothing

Any input would be greatly appreciated,

Anni