How can I determine what server an agent is executing on -- not a scheduled agent - lotus-domino

I need to capture which server an agent is running on. When the agent is a scheduled agent, I can use property NotesAgent.ServerName. But when the agent is executed from a url, 'ServerName' is blank. Is it possible to get the server name?

Found it: NotesSession.CurrentDatabase.Server
clem

You can access the Server property of the NotesDatabase class, like this:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim ag As NotesAgent
Set db = session.Currentdatabase
Set ag = session.Currentagent
If ag.Iswebagent then
MsgBox db.server
End if

Related

Changing Linked Table Source Access 2016

I am trying to change the links in an Access 2016 database, but the method I've used in the past is not working as required.
I am using the
t.connect="new connection"
t.refreshlink
method, where t is a the table.
I have seen in the linked table manager that the tables are now grouped by a data source. I can create the new source and link it to the desired table, but I have many as migrating, so would like to do this in code.
I get no errors the current way, but immediately after the .refreshlink the table's .connect is still the same.
Is this still possible?
I currently populate a dictionary with the table name and it's existing connection, but only if non ODBC.
I am then looping through this dictionary, getting the table and changing its connection
CurrentDb.TableDefs(strTableName).Connect = strNewConnection
CurrentDb.TableDefs(strTableName).RefreshLink
Debug.Print CurrentDb.TableDefs(strTableName).Connect
Existing connection = ;DATABASE=\\app01\Access\CRM_Data.mdb
New connection =;DATABASE=C:\CRM_TEST\CRM_DATA_BE_2016.accdb
Many thanks
You should not use CurrentDb.TableDefs when changing tables, as that changes between calls and makes the reference to the tabledef where you change the connection string be a different one than the one where you refresh the link.
Dim d As DAO.Database
Set d = CurrentDb
d.TableDefs(strTableName).Connect = strNewConnection
d.TableDefs(strTableName).RefreshLink
AFAIK this behaviour is not version-dependent, so the code you provided should never have worked.
I am using this code in Access 2016 and it works just fine:
Public Function RelinkTables(environment As Integer)
On Error Resume Next
Dim tblDef As DAO.TableDef
For Each tblDef In CurrentDb.TableDefs
If tblDef.Connect <> "" Then
tblDef.Connect = GetConnectionString(environment)
tblDef.RefreshLink
End If
Next
End Function
Public Function GetConnectionString(environment As Integer) As String
Select Case environment
Case 1 ' connection to Test db
GetConnectionString = "your connection string to Test"
Case 2 ' connection to Prod db
GetConnectionString = "your connection string to Production"
End Select
End Function
If this would not work with your db than may be the path is wrong.

VBA is unable to create a connection to a remote SQL Database

I've created an excel front end interface to connect with and manipulate an SQL database. I recently received a laptop, and would like to be able to manipulate the data from excel on said laptop. I established a connection using SQL Server Management Studios to the database.
I've tried to update my excel file; however, the VBA code can not connect to the SQL database. I've changed a few of the variables around and set Integrated Security too, but nothing has worked so far. The error message readouts can be seen here:
Here is the code related to the DB connection:
Dim cnSQL As ADODB.Connection
Set cnSQL = New ADODB.Connection
cnSQL.Open "Provider = SQLOLEDB; Integrated Security = SSPI, Data Source = IP Address,Static TP Port; UID = username; PWD =pwd#; Initial Catalog = database"
The error message highlights the second line of code. I'm hoping to be able to connect to the DB from my laptop.
After struggling for a few days, I finally got this to work. There are two important steps you need to take to make excel work with a Remote SQL network. First here is the code used to connect:
Dim cnSQL As ADODB.Connection
Dim ServerName As String
Dim DatabaseName As String
Dim userID As String
Dim password As String
ServerName = "IP Addresss,Port"
DatabaseName = "DB Name"
userID = "username"
password = "pwd"
Set cnSQL = New ADODB.Connection
sqlCommand.ActiveConnection = cnSQL
After I changed the code to this, I got a new error: "optional feature not implemented." To fix this error, I changed the data type of all 'adDate' to 'adDBTimeStamp.' This works for some reason, I don't know why. It works.

How let Access release the ODBC

I have 2 access databases, one in use as CRM and the other only holds linked tables to a firebird database using ODBC. This firebird database (fdb) is only capable to allow access to one user.
When updating the tables by the CRM through ODBC, the ODBC connection (Firebird) is not released, which means that an other application which needs access cannot open the database. The ODBC connection is only released when the CRM is closed.
Dim dba as database
Dim strODBCname as string
strODBCname = "OSF_ODBC.accdb"
Set dbs = OpenDatabase(ValidatePath(CurrentProject.Path, False) & strODBCname)
dbs.execute .... (etc.)
And after all record R/W are completed
set dbs = nothing
Is there an other way to enforce the release of the ODBC connection?
Peter
I've currently no idea how to explicitely release the ODBC connections of the current session, but you could open the database in a second Access application session (a second MsAccess.exe in memory) and release this after work:
Const ODBC_NAME As String = "OSF_ODBC.accdb"
With CreateObject("Access.Application")
.OpenCurrentDatabase ValidatePath(CurrentProject.Path, False) & ODBC_NAME
.CurrentDb.Execute ...
.CurrentDb.Close
.Quit
End With
This should release the connections for sure.
I don't know which version of Access you are using. But before you create a new application object, you should try
Set wrkAcc = CreateWorkspace("", "admin", "", dbUseJet)
Set dbs = wrkAcc.OpenDatabase(ValidatePath(CurrentProject.Path, False) & strODBCname)
or the next level up:
dim dbe=dao.dbengine
set dbe=CreateObject("dao.dbengine")
Set dbs= dbe.OpenDatabase(ValidatePath(CurrentProject.Path, False) & strODBCname)
More globally, you can modify the registry settings that control ODBC connection caching.

Creating a workspace session using SAS IOM & VBA

I am trying to connect to a workspace server using Excel VBA. Using the information on this page, I have produced the following:
Dim obSAS As SAS.Workspace
Dim obWorkspaceManager As New SASWorkspaceManager.WorkspaceManager
Private Sub Form_Load()
Dim obConnection As New ADODB.Connection
Dim obRecordSet As New ADODB.Recordset
Dim obServerDef As New SASWorkspaceManager.ServerDef
Dim xmlString As String
obServerDef.Port = 28561
obServerDef.Protocol = ProtocolBridge
obServerDef.MachineDNSName = "blah.server.com"
Set obSAS = obWorkspaceManager.Workspaces.CreateWorkspaceByServer( "Ref", _
VisibilityProcess, obServerDef, "me#saspw","MyPass", xmlStr)
end sub
My first response was this:
<xml id="combridgeOutput"><connectionAttempts><connectionAttempt>
<sasserver></sasserver>
<sasmachinednsname>blah.server.com</sasmachinednsname>
<sasport>28561</sasport>
<saslogin>me#saspw</saslogin>
<status>0x80041001</status>
<description><Exceptions><Exception>
<SASMessage severity="Error">
The client has connected to a SAS (9.2) Metadata Server (v1.0) when
it intended to connect to a SAS Workspace Server.
</SASMessage>
</Exception></Exceptions></description>
</connectionAttempt></connectionAttempts></xml>
So I updated the port number to point at the workspace server, and now I get this:
<same XML tags as above >
<SASMessage severity="Error">
Client me#saspw does not have permission to use server
SASMeta - Workspace Server (A5DPDN69.AV000069).
</SASMessage>
Would rather not set special permissions for this exercise. How else can one connect VBA to a SAS workspace server session?
Doh! I was using the wrong machine name. For reference, here is the process for getting the correct machine name!
Log into SMC
Expand Server Manager
Expand SASApp
Expand SASApp - Logical Workspace Server
There you will see the correct machine, and will also show the port details..

How do I connect an SQL database to Lotus Domino Designer?

I am creating a Lotus Notes application which has to have dynamic combo boxes. The choices for the combo boxes need to be retrieved by selecting from a SQL database.
I am new to Lotus Notes / Domino, I would love to know how to connect my SQL database for use in the domino designer. Thanks.
Edit: this is the client, not the web
Sub Initialize
On Error GoTo e
Dim pw As String,user As String,odbc As String
Dim i As Integer
Dim conn As ODBCConnection,query As ODBCQuery,rs As ODBCResultSet
Dim db As NotesDatabase
Dim session As NotesSession
Dim view As NotesView
Dim doc As NotesDocument
Dim newDoc As NotesDocument
Set session = New NotesSession
Set db = session.CurrentDatabase
Set view = db.GetView("Reports")
Set doc = view.GetFirstDocument
Set conn = New ODBCConnection
Set query = New ODBCQuery
Set rs = New ODBCResultSet
Set query.Connection = conn
Set rs.Query = query
odbc = "server"
user = "user"
pw = "pass"
Call conn.ConnectTo( odbc , user , pw )
i = 0
query.SQL = "SELECT * FROM table"
rs.Execute
rs.FirstRow
Do While Not rs.IsEndOfData
i = i + 1
rs.NextRow
Loop
conn.Disconnect
Exit Sub
e :
MessageBox "Error " & Err & " line " & Erl & ": " & _
Error
Exit Sub
End Sub
The questions is tagged Lotusscript so I assume that this is Lotusscript related (and not XPages related).
Have a look at the ODBCConnection, ODBCQuery, and ODBCResultSet Lotusscript classes in the Domino Designer Help database.
If you're not able to use any XPages components, you could try the ODBC variant of #DBLookup in the 'Use formula for choices' part of your combobox.
The code you have added to the question is going to cause an infinite loop due to the while/wend
Depending on how often the choices for the dropdown boxes change you could also create a scheduled agent that connections to the SQL server. I do this a lot for some of my own internal applications as it cuts down on unnecessary traffic to the SQL server if the values being returned are always the same.
Your scheduled agent would need to use the LSXLC extensions by adding UseLSX "*lsxlc" to the options section of the Lotusscript agent.
The LSXLC has a LOT of options which would be beyond the scope of this question so I would recommend looking at the Domino Designer Help files and searching for lsxlc. There are lots of examples in the help files.
Have a look at extlib on OpenNTF. It has an XPages component that allows you to connect to make SQL calls.
http://extlib.openntf.org
if you are using an xpages application, you can use a managed bean or static java method to get the data you want and bind it to the select values of the of combobox control.