Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Delphi
  4. Parameterized ADOQuery

Parameterized ADOQuery

Scheduled Pinned Locked Moved Delphi
databasetutorialdelphicomquestion
4 Posts 3 Posters 6 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dave kelly
    wrote on last edited by
    #1

    I have inherited a Delphi project, and as a non-Delphi programmer I am only just getting to grips with its various strange idiosyncrasies. One aspect of the application I am working on relates to an ADOQuery, and the formats with dates. The query is written parameterized, however I have noticed incorrect datasets particularly at the start of a new month. I am guessing this is due to the SQL syntax normally using the US date format, whereas the system date is in the UK format. I googled a few attempts at setting the date format, and found that using the parameterized is the best version, as then it doesn't matter what format is passed. However I can't get the suggested methods to compile, using the AsDateTime:

    adoQuery.Parameters.ParamByName('TimeNow').AsDateString

    Example from http://en.allexperts.com/q/Delphi-1595/2009/2/School-Project-2.htm[^] Any hints on how to handle this situation?

    R 1 Reply Last reply
    0
    • D dave kelly

      I have inherited a Delphi project, and as a non-Delphi programmer I am only just getting to grips with its various strange idiosyncrasies. One aspect of the application I am working on relates to an ADOQuery, and the formats with dates. The query is written parameterized, however I have noticed incorrect datasets particularly at the start of a new month. I am guessing this is due to the SQL syntax normally using the US date format, whereas the system date is in the UK format. I googled a few attempts at setting the date format, and found that using the parameterized is the best version, as then it doesn't matter what format is passed. However I can't get the suggested methods to compile, using the AsDateTime:

      adoQuery.Parameters.ParamByName('TimeNow').AsDateString

      Example from http://en.allexperts.com/q/Delphi-1595/2009/2/School-Project-2.htm[^] Any hints on how to handle this situation?

      R Offline
      R Offline
      rickyjos
      wrote on last edited by
      #2

      Hello, I would do like this;

      adoQuery.Parameters.ParamByName('TimeNow').DataType := ftDateTime;
      adoQuery.Parameters.ParamByName('TimeNow').Value := mydatevalue;

      B D 2 Replies Last reply
      0
      • R rickyjos

        Hello, I would do like this;

        adoQuery.Parameters.ParamByName('TimeNow').DataType := ftDateTime;
        adoQuery.Parameters.ParamByName('TimeNow').Value := mydatevalue;

        B Offline
        B Offline
        Blue_Boy
        wrote on last edited by
        #3

        Only adoQuery.Parameters.ParamByName('TimeNow').Value := mydatevalue; will work without problem :)


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

        1 Reply Last reply
        0
        • R rickyjos

          Hello, I would do like this;

          adoQuery.Parameters.ParamByName('TimeNow').DataType := ftDateTime;
          adoQuery.Parameters.ParamByName('TimeNow').Value := mydatevalue;

          D Offline
          D Offline
          dave kelly
          wrote on last edited by
          #4

          Thanks to both for the replies. After some experimentation, I found that it was necessary to set the DataType for the parameter, else it did not give correct datasets for the query.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups