【问题标题】:Make pre-prepared sql command in libreoffice basic在 libreoffice basic 中制作预先准备好的 sql 命令
【发布时间】:2021-07-02 09:31:58
【问题描述】:

我正在尝试根据我在 libreoffice basic 中的表单中的字段中的值进行准备好的查询。为此,我创建了一个宏。 但它在查询行上返回一个错误说

基本语法错误。 意外符号:oInstruction_SQL

Sub concatMotherName

Dim oSourceDonnees As Object
Dim oConnexion As Object
Dim stSql As String
Dim oResultat As Object

oSourceDonnees = thisComponent.Parent.dataSource
oConnexion = oSourceDonnees.getConnection("","")
oInstruction_SQL = oConnexion.createStatement()
Dim valueData As String
Dim dateLabel As String

valueData = ThisComponent.Drawpage.Forms.getByName("Form").getByName("id_mother_label").getCurrentValue()
stSql = "SELECT NOM_MERE FROM ""T_MOTHER"" WHERE ""NUM_MOTHER"" = ?" _
oInstruction_SQL = = oConnection.prepareStatement(stSql)
oInstruction_SQL.setString(1, valueData)
oResultat = oInstruction_SQL.executeQuery(stSql)
If Not IsNull(oResultat) Then
   oResultat.Next()
   MsgBox oResultat.getString(1)
End If
End Sub

【问题讨论】:

    标签: libreoffice-basic


    【解决方案1】:

    有两个语法问题。第一个是查询字符串后的_,表示下一行是该行的延续。这不是续集,所以删除它。

    第二个错误在下一行:= =

    修复这些错误后,代码编译成功。

    【讨论】:

    • 天哪,我没看到...非常感谢!
    猜你喜欢
    • 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
    相关资源
    最近更新 更多