PdcDBQuery.SetParamStr: Difference between revisions

From External Bemet Wiki
Jump to navigation Jump to search
Created page with "== Declaration == SetParamStr(ParameterName as string, Value as string) as boolean == Description == Changes the value of the parameter with a specific name to 'Value'. == No..."
 
No edit summary
Line 12: Line 12:


<source lang="vb">
<source lang="vb">
Sub sExecuteQuery
    Dim myQuery As PDCEXT.IDBQuery = PDC.App.Database.OpenQuery(PDCEXT.pdcConnectionKind.pdcConData)
dim objQuery
    myQuery.SQL = "SELECT * FROM LK_KLANT WHERE KL_PLAATS=:ParamOne AND KL_VINK1=:ParamTwo"
    myQuery.SetParamStr("ParamOne", "Amsterdam")
    myQuery.SetParamBool("ParamTwo", True)


  set objQuery = pdc.Database.OpenQuery(pdcConData)
    If myQuery.Execute Then
  objQuery.SQL = "SELECT * FROM LK_KLANT WHERE KL_PLAATS=:ParamOne AND KL_VINK1=:ParamTwo"
      MsgBox(myQuery.GetField("KL_NAAM"))
  objQuery.SetParamStr  "ParamOne", "Amsterdam"
    Else
  objQuery.SetParamBool "ParamTwo", True
      MsgBox($"Error: {PDC.App.LastError}")
 
    End If
  if objQuery.Execute then
    msgbox objQuery.GetField("KL_NAAM")
  else
    msgbox "Error:" & vbCrLf & pdc.LastError & vbCrLf & vbCrLf & "SQL:" & vbCrLf & objQuery.SQL
  end if
End Sub
</source>
</source>


== Availability ==
== Availability ==
Available since May 2019 (from version 5.5)
Available since May 2019 (from version 5.5)

Revision as of 13:48, 12 May 2020

Declaration

SetParamStr(ParameterName as string, Value as string) as boolean

Description

Changes the value of the parameter with a specific name to 'Value'.

Notes

Changes the value of the parameter with a specific name to 'Value'. The result returns it was succesfull or not.

Code example

This code example executes a SQL statement with parameters.

    Dim myQuery As PDCEXT.IDBQuery = PDC.App.Database.OpenQuery(PDCEXT.pdcConnectionKind.pdcConData)
    myQuery.SQL = "SELECT * FROM LK_KLANT WHERE KL_PLAATS=:ParamOne AND KL_VINK1=:ParamTwo"
    myQuery.SetParamStr("ParamOne", "Amsterdam")
    myQuery.SetParamBool("ParamTwo", True)

    If myQuery.Execute Then
      MsgBox(myQuery.GetField("KL_NAAM"))
    Else
      MsgBox($"Error: {PDC.App.LastError}")
    End If

Availability

Available since May 2019 (from version 5.5)