I give up and hope someone can see why my script is not creating a new document with the information I am retrieving from a SQL database. For testing I am only trying to get 1 document. I am getting no error but also no document. The script is an agent that I will put under an action button to kick it off. Any eyes are appreciated. Thank you all!
Below is my script:
Sub Initialize
Dim con As New ODBCConnection
Dim qry As New ODBCQuery
Dim res As New ODBCResultSet
Dim ws As New Notesuiworkspace
Dim uidoc As Notesuidocument
Dim datasource As String
Dim resultCon As Variant
Dim sess As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set db = sess.CurrentDatabase
datasource = “db.server/WAREHOUSE”
resultCon = con.ConnectTo(datasource)
Set uidoc = ws.CurrentDocument
If con.ConnectTo(“WAREHOUSE”, “”, “”) Then
Set qry.Connection = con
qry.SQL = “SELECT ownername, notebal, acctnbr from wh_acctcommon where acctnbr = ‘111’”
Set res.Query = qry
res.Execute
If res.IsResultSetAvailable = True Then
Do
res.FirstRow
Set doc = db.CreateDocument
With doc
.Form = "Main"
.Name = res.GetValue("Ownername")
.Acct = res.GetValue("AcctNbr")
.Save True,False
End With
Loop Until res.IsEndOfData
End If
res.Close(DB_CLOSE)
con.Disconnect
Else
Messagebox(“Could not connect to database server”)
I want to thank you all for your responses, however, I put in error handler and nothing, I walked through the debugger and everything is flowing. It even walks through the part to make the new document.
I use the SQL in numerous forms to go out to the SQL database and bring data into an existing form while the user is in the form.
You are not going to believe it, I found my documents, they were not in text format they were in numeric format. Sorry for all the trouble.