Solved

Creating Docs with an Agent

Posted on 2000-05-17
1
183 Views
Last Modified: 2013-12-18
I want to create an agent that uses an ODBC connection to get a Qry, Then for every record in the Qry create a new document in the database and populate the fields with the  Qry's current row.

I know how to set up the ODBC and get the backend data. I do not know how to create a new document, populate it's fields, then loop to create another new document. What would the code look like to do this?

I really just need to see a simple example of an agent looping and creating a new document each pass.
0
Comment
Question by:roosterup
1 Comment
 
LVL 3

Accepted Solution

by:
Simon_Hendry earned 50 total points
ID: 2819200
Here is a piece of skeleton code for odbc data extraction in to notes documents

----- CODE STARTS ------
' Specify this in options section of Code - it is required to load the ODBC 'Lotuscript Conduits for the ODBC Classes
Uselsx "*LSXODBC"


Dim con As New ODBCConnection
Dim qry As New ODBCQuery
Dim result As New ODBCResultSet
Dim OurDB As NotesDatabase
Dim NewDocument As NotesDocument

Set OurDB As New NotesDatabase("OurServerName","Members.nsf")
' Connect to the datasource
If Not con.ConnectTo("OurODBCSource") Then
Messagebox "Could not connect to Members",, "Error connecting"
Exit Sub
End If
' Set up the odbc objects
Set qry.Connection = con
Set result.Query = qry

' make a query for all of the data in the Members table
qry.SQL = "SELECT * FROM Members"


' and execute the query - and wait for the result set to fill up with data
result.Execute

' Now roll through each row of the result set and create a new document in our database for each row in the table
If result.IsResultSetAvailable Then
Do
result.NextRow

' Create the new document and load up the fields with data from the current row of the result set
Set NewDocument As New NotesDocument(OurDB)
NewDocument.Form = "New Member"
NewDocument.MembersName = result.GetValue("Name")
NewDocument.MembersAge = result.GetValue("Age")
NewDocument.MembersAddress = result.GetValue("Address")
Call NewDocument.Save(True,False)

Loop Until result.IsEndOfData

' dump the memory for the result set
result.Close(DB_CLOSE)

Else
' if we didn't get any data then inform the interactive user
Messagebox "No data retrieved for Members",, "No data"
Exit Sub
End If

' Close the connection to the ODBC Source
con.Disconnect

End Sub
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Invoke VBA from lotusscript after mailmerge 11 236
Notes > Exchange calendar issues 5 66
Adding a named anchor in a Lotus Notes Form 6 91
Counting documents in a Domino View 3 83
For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question