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. Database & SysAdmin
  3. Database
  4. DAO query by array long[] numbers

DAO query by array long[] numbers

Scheduled Pinned Locked Moved Database
databasedata-structureshelp
2 Posts 2 Posters 0 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.
  • A Offline
    A Offline
    arbrsoft
    wrote on last edited by
    #1

    I made a program using CDaoRecordSet with ACCESS97 database. And I want to query table data by array long[] that I have. long IDID[5]={7, 12, 14, 27, 33}; and I want to Do like this. CString ralp; //ID2 is a feild name of the table is named move in xx.mdb ralp.Format("ID2 LIKE %ld OR %ld OR %ld OR %ld OR %ld",IDID[0],IDID[1],IDID[2],IDID[3],IDID[4],IDID[5]"); m_pSet->m_strFilter=ralp; m_pSet->Requery(); But it goes wrong, it has just a one record though it must have 5. I want to query by my known numbers. Please help me. thanks.

    S 1 Reply Last reply
    0
    • A arbrsoft

      I made a program using CDaoRecordSet with ACCESS97 database. And I want to query table data by array long[] that I have. long IDID[5]={7, 12, 14, 27, 33}; and I want to Do like this. CString ralp; //ID2 is a feild name of the table is named move in xx.mdb ralp.Format("ID2 LIKE %ld OR %ld OR %ld OR %ld OR %ld",IDID[0],IDID[1],IDID[2],IDID[3],IDID[4],IDID[5]"); m_pSet->m_strFilter=ralp; m_pSet->Requery(); But it goes wrong, it has just a one record though it must have 5. I want to query by my known numbers. Please help me. thanks.

      S Offline
      S Offline
      Steve S
      wrote on last edited by
      #2

      Personally, I'd use "ID2 IN (%ld,%ld,%ld,%ld)" but then, I'm picky. The requery is likely to fail anyway, since (1) LIKE is applied to a string field, NOT a numeric type, and (2) the syntax should be ID2 LIKE 'x' OR ID2 LIKE 'y' OR ID2 LIKE 'z' Be aware that there is an upper limit (although I forget what) as to how many elements you can put in an IN clause. Using IN is more convenient if there isn't a fixed number of elements, since you can append ",value" data easily. Steve S

      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