Hello,
While tested on a Linux system with a MySQL ODBC connection, the same process should work for you.
You just need to add user & password:
Dim oParms() As New com.sun.star.beans.PropertyValue
AppendProperty(oParms(), "user", sUser)
AppendProperty(oParms(), "password", sPass)
For security, provide input box to enter actual User & Password info.
Then also change one line in routine.
From:
oCon = oManager.getConnection(sURL)
To:
oCon = oManager.getConnectionWithInfo(sURL, oParms())
Edit 2/27/18:
This sub also needs to be added:
Sub AppendProperty(oProperties(), sName As String, ByVal oValue)
AppendToArray(oProperties(), CreateProperty(sName, oValue))
End Sub
which uses this Function:
Function CreateProperty(sName$, oValue) As com.sun.star.beans.PropertyValue
Dim oProperty As New com.sun.star.beans.PropertyValue
oProperty.Name = sName
oProperty.Value = oValue
CreateProperty() = oProperty
End Function
and this Sub:
Sub AppendToArray(oData(), ByVal x)
Dim iUB As Integer 'The upper bound of the array.
Dim iLB As Integer 'The lower bound of the array.
iUB = UBound(oData()) + 1
iLB = LBound(oData())
ReDim Preserve oData(iLB To iUB)
oData(iUB) = x
End Sub
I apologize for the inconvenience. All of the above is taken from the aforementioned ‘AndrewBase’ document.
If this answers your question please tick the (upper left area of answer). It helps others to know there was an accepted answer.