The script, when executed from a button, will create a new record in a specified ODBC data
source, attempt to save the new record and display a message indicating whether the operation was
completed successfully. If the operation is not completed sucessfully, it is likely that
either your data source is read-only or your ODBC driver does not permit updates to the data
source.
Important: Complete each of the four steps below before running the script.
1. Create a new agent and add the following UseLSX command to the Options event:
UseLSX "*LSXODBC"
2. Add the following script to the Initialize event of the agent. NOTE: Do not add the 'Sub'
and 'End Sub' lines.
Dim ui As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim connection As ODBCConnection
Dim query As ODBCQuery
Dim result As ODBCResultSet
Set uidoc=ui.CurrentDocument
Set doc=uidoc.Document
Set connection = New ODBCConnection
Set query = New ODBCQuery
Set result = New ODBCResultSet
Set query.Connection = connection
Set result.Query = query
Call connection.ConnectTo("mydatasource", "root", "1989ashok")
If connection.IsConnected Then
Msgbox "Connected"
'get employee id and fetch corresponding record
query.SQL="select * from employee where employeeid="+doc.numEmpID(0)+""
Msgbox query.SQL,,"Query"
Call result.Execute
If result.IsResultSetAvailable Then
Do
result.NextRow
doc.txName=result.GetValue("name")
doc.numAge=result.GetValue("age")
doc.txDesignation=result.GetValue("designation")
Loop Until result.IsEndOfData
Else
Msgbox "no record found"
End If
result.Close(DB_CLOSE)
connection.Disconnect
Else
Msgbox "connection could not be established"
End If
source, attempt to save the new record and display a message indicating whether the operation was
completed successfully. If the operation is not completed sucessfully, it is likely that
either your data source is read-only or your ODBC driver does not permit updates to the data
source.
Important: Complete each of the four steps below before running the script.
1. Create a new agent and add the following UseLSX command to the Options event:
UseLSX "*LSXODBC"
2. Add the following script to the Initialize event of the agent. NOTE: Do not add the 'Sub'
and 'End Sub' lines.
Dim ui As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim connection As ODBCConnection
Dim query As ODBCQuery
Dim result As ODBCResultSet
Set uidoc=ui.CurrentDocument
Set doc=uidoc.Document
Set connection = New ODBCConnection
Set query = New ODBCQuery
Set result = New ODBCResultSet
Set query.Connection = connection
Set result.Query = query
Call connection.ConnectTo("mydatasource", "root", "1989ashok")
If connection.IsConnected Then
Msgbox "Connected"
'get employee id and fetch corresponding record
query.SQL="select * from employee where employeeid="+doc.numEmpID(0)+""
Msgbox query.SQL,,"Query"
Call result.Execute
If result.IsResultSetAvailable Then
Do
result.NextRow
doc.txName=result.GetValue("name")
doc.numAge=result.GetValue("age")
doc.txDesignation=result.GetValue("designation")
Loop Until result.IsEndOfData
Else
Msgbox "no record found"
End If
result.Close(DB_CLOSE)
connection.Disconnect
Else
Msgbox "connection could not be established"
End If
I executed a similar code above. But the agent taking long time (more than 5mins) to process the below line. Anyone know the reason?
ReplyDeletequery.SQL="select * from employee where employeeid="+doc.numEmpID(0)+""