Le 29/12/2014 00:20, craig48 a écrit :
When I open the form, the database password is requested and I enter it, and
the form's grid is loaded with the data. I'm having trouble connecting from
the form using a basic macro. The connection requires a password. Running
the following code produces an error at the getConnection statement:
sURL = "sdbc:mysql:mysqlc:sys76.localdomain:3306/folding"
oManager = CreateUnoService("com.sun.star.sdbc.DriverManager")
oCon = oManager.getConnection(sURL)
Your connection context needs to be complete. Unfortunately, the short
snippet you have given here doesn't show enough information as to
whether or not you've defined the requisite objects and VARs.
The resulting error is:
BASIC runtime error.
An exception occurred
Type: com.sun.star.sdbc.SQLException
Message: Access denied for user 'craig'@'mac.localdomain' (using password:
NO).
This would indicate that you either haven't passed, or defined the
connection string (uid/pwd) correctly, or else are trying to access the
remote instance via an incorrectly defined host string.
Try using the URL interaction handler :
Sub ConnectDBSource_withPwd()
Dim SourceName as String, AskPwd as Object
Dim mySource as Object, myDBContext as Object
SourceName = "Test"
myDBContext = CreateUnoService("com.sun.star.sdb.DatabaseContext")
mySource = myDBContext.getByName(SourceName)
AskPwd = CreateUnoService("com.sun.star.sdb.InteractionHandler")
mySource.IsPasswordRequired = true
myConnection = mySource.connectWithCompletion(AskPwd)
if IsNull(myConnection) then
MsgBox("Connection failed", 16)
Stop
end if
End Sub
Alex
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.