Scheduled Agent Problem

Hi, I have this agent written in lotus scriptThe agent uses LSX and ODBC when i run this agent manually its works perfectly( it extracts data from an MS access file and deletes those records extracted from Access)

however when this is run on the server the agent runs without any error showing up on the server console however there is no effect i.e(records are not extracted from the server).

I have tried everything i could think of to make it work but still the same problem.

  • LSX library and ODBC connections have been setup on the server

code

–Options

Option Public

Uselsx “nlsxodbc.dll”

–Declerations

%INCLUDE “lsconst.lss”

%INCLUDE “lsxbeerr.lss”

Sub Initialize

	REM  MS Access Reader by Gary Roberts  08/30/2000   

REM Copyright Gary Roberts, 2000 (e-mail: groberts@carolina.rr.com)

REM

REM Application Name: MS Access Reader

REM View Name: Customers

REM Action Name: Read MS Access Database

REM

REM Purpose:

REM Read a Microsoft Access (MS Access) MDB file and create a Notes Document for

REM each record in the MS Access Database. The newly created documents will be

REM displayed in the “By Company Name” view in THIS Notes Database.

REM

REM IMPORTANT NOTES:

REM You do NOT have to have MS Access installed on your PC to run this program.

REM You DO have to have the Northwind.mdb file (comes with MS Access)

REM You DO have to register Northwind.mdb as an ODBC Data Source (System)

REM You DO have to have nlsxodbc.dll in your Notes directory (NOT the Data Directory)

REM You DO have to have lsconst.lss in your Notes directory (NOT the Data Directory)

REM You DO have to have lsxbeerr.lss in your Notes directory (NOT the Data Directory)

REM The ODBC LSX File is declared in the FORM’s (Globals) (Options) section

REM I used the fully qualified filename of the DLL in case yours isn’t registered

REM LotusScript and Error constants are “Included” in the FORM’s (Globals) (Declarations) section

REM

REM Change Log:

REM ------------------------------------------------------------------------------------------------------

REM 08/30/2000 Gary Roberts Placed into production

REM

REM Notes Objects Declarations

Dim session As New NotesSession

'Dim ws As New NotesUIWorkspace

Dim con As New ODBCConnection

Dim qry As New ODBCQuery

Dim result As New ODBCResultSet

REM Miscellaneous module variables

REM MS Access Database declarations

Const adbFileName = "callender"  ' This is the DSN Name as registered in ODBC

Const adbTableName = "appointment"  ' This is a table in the northwind database

REM Notes Database declarations

Const ndbViewName = "By Company Name"  ' This is an existing View in the target database

Const ndbFormName = "Customer"  ' This is an existing Form in the target database

REM Instantiate the major Notes objects

Set db = session.CurrentDatabase     

'Set view = db.GetView( ndbViewName )

REM Connect to the MS Access Database. Throw an error if it fails

status = con.ConnectTo( adbFileName )

If Not con.IsConnected Then

	REM Messagebox "Could not connect to " & adbFileName & " database -- Did you register the ODBC Data Source???",, "Error"

	Exit Sub

End If

If con.GetError <> DBstsSUCCESS Then

REM	Messagebox con.GetExtendedErrorMessage,, "Connection Error - " & con.GetError & " " & con.GetErrorMessage

	Exit Sub

End If

REM Print "Connected to " & adbFileName & " database"  ' Update the Notes Client Status Bar if we're okay

REM If we got this far, we must be connected, so just for grins, let’s show the user all the fields in this table.

REM Note: “fields” has not been declared, so it will be a Variant Array – that’s what we want

fields = con.ListFields( adbTableName )

msg = adbTableName & " contains the following fields:" & Chr(10)

For FieldCount = Lbound( fields ) To Ubound( fields )

	msg = msg & Chr(10) & fields( FieldCount )

Next

REM Okay, let’s display the Field List to the User…

REM Messagebox msg,, "Fields from the " & adbFileName & " database"

REM We made it this far, so let’s setup the SQL Query. Throw an error if it fails

Set qry.Connection = con

Set result.Query = qry

qry.SQL = "SELECT * FROM " & adbTableName  ' Grab all of the fields (columns) from the specified table

If qry.GetError <> DBstsSUCCESS Then

	'Messagebox qry.GetExtendedErrorMessage,, "Query Error" & qry.GetError & " " & qry.GetErrorMessage

	Exit Sub

End If

REM Update the Notes Client Status Bar

'Print "Reading " & adbFileName & " database"  ' Update the Notes Client Status Bar if we're okay

REM Must be okay – Get the Data

result.Execute

REM See if we have data. If so, loop through the ResultSet. If not, throw an error

If result.IsResultSetAvailable Then

	Do

		result.NextRow

    REM  Create a Notes Document, assign values, save the document.  Do it until we're done.

		

		If (result.GetValue("type_id") <>1) Then

			

			

			Set doc = db.CreateDocument  ' Create a new Notes Document for this record

			doc.Form = ndbFormName

    REM  Okay -- Let's get serious -- We'll use the MS Access Database field (Column)

    REM  names for the field names in the Notes Documents

			doc.ID = result.GetValue( "id" )

			doc.From = result.GetValue( "from" )

			doc.To =  result.GetValue( "to" ) 

			doc.Date =  result.GetValue( "date" ) 

			doc.subject =result.GetValue("varified")

			doc.Message =  result.GetValue( "time" ) 

			'Call result.SetValue(6,1)

			Call result.DeleteRow("appointment")

			Call doc.save( True, False )

			

		End If

	Loop Until result.IsEndOfData

	

REM  We're done, so let's clean up the mess we've made and bail out  

	result.Close( DB_CLOSE )

	'Print "Finished"  ' Update the Notes Client Status Bar if we're okay

Else

REM  If we got here, it means there was no data in the table, so throw an error (Informational)

	'Messagebox "No data retrieved for " & adbTableName & " table", MB_ICONINFORMATION, "No data"

	'Print "DOH!!!!!  Got no data -- Bummer!!!!"  ' Update the Notes Client Status Bar if we're NOT okay

	Exit Sub  

End If

REM Give up the ODBC Connection like a good little boy

con.Disconnect

REM Update the view so the new documents will show up without having to press the F9 key

'Call view.Refresh

'Call ws.ViewRefresh

End Sub

Subject: Scheduled Agent Problem

Normally I find if something works when you run it manually but not on the server then it is an access rights problem.

Try getting the agent signed by the server if it is not already. If this still doesn’t work then there is a Trusted Server field in names.nsf. When I had this problem this field was blank so I got an Administrator to put Local Domain Servers in this field and the problem was fixed.

From what I can remember this field controls which servers are allowed to connect to other servers.

Subject: Scheduled Agent Problem

is the server set up to make calls to SQL server? ie. are the odbc drivers installed ?

Basically what is stated in the comments of your agent:

REM You do NOT have to have MS Access installed on your PC to run this program.

REM You DO have to have the Northwind.mdb file (comes with MS Access)

REM You DO have to register Northwind.mdb as an ODBC Data Source (System)

REM You DO have to have nlsxodbc.dll in your Notes directory (NOT the Data Directory)

REM You DO have to have lsconst.lss in your Notes directory (NOT the Data Directory)

REM You DO have to have lsxbeerr.lss in your Notes directory (NOT the Data Directory)

is that true for the server ?

Subject: Scheduled Agent Problem

When I have seen this, the most common problem has been the ODBC connection name on the server not exactly matching the ODBC connection name from the PC I’m using to test manually; if you manually run the agent, it uses local PC ODBC connection info, if you let it run scheduled it uses the info from the server.

You may want to check if the two are actually identical or not.

Subject: RE: Scheduled Agent Problem

Thak you everyone - i finally figured out the problem the DSN on the server was a User DSN and not a System DSN.

When a User DSN is specified it can not be accessed through a scheduled agent as lotus probably uses the nt service(System) account.

Long story short

Changed from user DSN to System DSN now its working fine - the only issue with the system dsn is that you can not make an odbc connection for a database that is on a network path and not on the local(server) pc