【问题标题】:LibreOffice BASIC : Connect to PostgreSQLLibreOffice BASIC:连接到 PostgreSQL
【发布时间】:2019-02-27 13:49:49
【问题描述】:

我已经使用 LibreOffice Base (6.1) 创建了一个 PostgreSQL 连接文件,我可以在那里运行 SQL 查询,但我想知道是否可以在 LibreOffice BASIC 函数中使用这个 Base 连接。

我知道你可以为 MySQL 使用 JDBC 连接

mysql://hostname:port/database_name

但我希望有一种方法可以使用基本文件,因为它运行良好

我一直试图在网上找到有关此的文档,但我很难找到任何可以弥合 BASIC 和 Base 之间差距的东西。

【问题讨论】:

    标签: postgresql libreoffice-basic libreoffice-base


    【解决方案1】:

    我找到了答案,解决方案是使用 createUnoService,它允许您指定在 Base 中设置的 odb 的名称。

    oService = createUnoService("com.sun.star.sdb.DatabaseContext")
    oBase = oService.getByName("basePostgreSQL")
    oConn = oBase.getConnection("","")
    
    oQuery = oConn.createStatement()
    oSql = "select col from table"
    
    oResult = oQuery.executeQuery(oSql)
    while oResult.next()
        msgBox oResult.getString(1)
    wend
    
    oConn.close()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多