Solved

Creating Docs with an Agent

Posted on 2000-05-17
1
184 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

856 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