PdcDBQuery.SetParamDate: Difference between revisions

From External Bemet Wiki
Jump to navigation Jump to search
Created page with "== Declaration == SetParamDate(ParameterName as string, Value as Date) as boolean == Description == Changes the value of the parameter with a specific name to 'Value'. == No..."
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 17: Line 17:


   set objQuery = pdc.Database.OpenQuery(pdcConData)
   set objQuery = pdc.Database.OpenQuery(pdcConData)
   objQuery.SQL = "SELECT *
   objQuery.SQL = "SELECT do_ordnr
                   FROM LK_KLANT
                   FROM do_calc
                   WHERE KL_PLAATS=:ParamOne AND KL_VINK1=:ParamTwo AND  
                   WHERE do_kstsrt=:ParamOne AND do_vink1=:ParamTwo AND  
                         kl_invoer=:ParamThree AND kl_invoer=:ParamFour AND  
                         do_lever=:ParamThree AND do_datin=:ParamFour AND  
                         kl_dagen=:ParamFive AND kl_limiet=:ParamSix"
                         do_prdcmb=:ParamFive AND do_fact=:ParamSix"


   objQuery.SetParamStr      "ParamOne", "Amsterdam"
   objQuery.SetParamStr      "ParamOne", "8000"
   objQuery.SetParamBool    "ParamTwo", True
   objQuery.SetParamBool    "ParamTwo", True
   objQuery.SetParamDate    "ParamThree", Date()
   objQuery.SetParamDate    "ParamThree", Date()
   objQuery.SetParamDateTime "ParamFour", Now()
   objQuery.SetParamDateTime "ParamFour", Now()
   objQuery.SetParamInt      "ParamFive", 30
   objQuery.SetParamInt      "ParamFive", 1003456
   objQuery.SetParamDbl      "ParamSix", 10000.0
   objQuery.SetParamDbl      "ParamSix", 678.56
    
    
   if objQuery.Execute then
   if objQuery.Execute then
     msgbox objQuery.GetField("KL_NAAM")
     if not objQuery.Eof then
      dim strCalcNo   
      strCalcNo = objQuery.GetField("do_ordnr")
      msgbox strCalcNo
   
      objQuery.SQL = "update do_calc
                      set do_image = :ImageFromFile
                      where do_ordnr=:CalcNo"
 
      objQuery.SetParamStr          "CalcNo", strCalcNo
      objQuery.SetParamBlobFromFile "ImageFromFile", "c:\temp\filename.pdf"
      if not objQuery.Execute then
        msgbox "Error:" & vbCrLf & pdc.LastError & vbCrLf & vbCrLf & "SQL:" & vbCrLf & objQuery.SQL
      end if
    end if
   else
   else
     msgbox "Error:" & vbCrLf & pdc.LastError & vbCrLf & vbCrLf & "SQL:" & vbCrLf & objQuery.SQL
     msgbox "Error:" & vbCrLf & pdc.LastError & vbCrLf & vbCrLf & "SQL:" & vbCrLf & objQuery.SQL

Latest revision as of 09:21, 19 January 2021

Declaration

SetParamDate(ParameterName as string, Value as Date) 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.

Sub sExecuteQuery
dim objQuery

  set objQuery = pdc.Database.OpenQuery(pdcConData)
  objQuery.SQL = "SELECT do_ordnr 
                  FROM do_calc 
                  WHERE do_kstsrt=:ParamOne AND do_vink1=:ParamTwo AND 
                        do_lever=:ParamThree AND do_datin=:ParamFour AND 
                        do_prdcmb=:ParamFive AND do_fact=:ParamSix"

  objQuery.SetParamStr      "ParamOne", "8000"
  objQuery.SetParamBool     "ParamTwo", True
  objQuery.SetParamDate     "ParamThree", Date()
  objQuery.SetParamDateTime "ParamFour", Now()
  objQuery.SetParamInt      "ParamFive", 1003456
  objQuery.SetParamDbl      "ParamSix", 678.56
  
  if objQuery.Execute then
    if not objQuery.Eof then
      dim strCalcNo    
      strCalcNo = objQuery.GetField("do_ordnr")
      msgbox strCalcNo 
    
      objQuery.SQL = "update do_calc 
                      set do_image = :ImageFromFile
                      where do_ordnr=:CalcNo"

      objQuery.SetParamStr          "CalcNo", strCalcNo
      objQuery.SetParamBlobFromFile "ImageFromFile", "c:\temp\filename.pdf"
      if not objQuery.Execute then
        msgbox "Error:" & vbCrLf & pdc.LastError & vbCrLf & vbCrLf & "SQL:" & vbCrLf & objQuery.SQL
      end if
    end if
  else
    msgbox "Error:" & vbCrLf & pdc.LastError & vbCrLf & vbCrLf & "SQL:" & vbCrLf & objQuery.SQL
  end if
End Sub

Availability

Available since May 2019 (from version 5.5)