?
Solved

Creating Docs with an Agent

Posted on 2000-05-17
1
Medium Priority
?
195 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 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

839 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