Solved

Creating Docs with an Agent

Posted on 2000-05-17
1
180 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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Lotus Notes 6.5.5 6 200
Lotus Domino 9.0 install on same pc with 8.5.3 9 113
Lotus Domino server 9 7 64
Lotus Domino 9 web server 6 74
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now