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. C / C++ / MFC
  4. *** Retriving Rows of Data from Access Tables **

*** Retriving Rows of Data from Access Tables **

Scheduled Pinned Locked Moved C / C++ / MFC
4 Posts 3 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.
  • S Offline
    S Offline
    Steve Lai
    wrote on last edited by
    #1

    Hi Everyone, I’m using Visual C++6, and I have this question regarding Database programming with Microsoft Access. How do I get a certain row’s field names and it’s values?? For example, let’s say I have an Access table such as: CustID CustName Item Price 1 John Pen 1.99 2 Mike Mirror 5.00 3 Erin Pencils 1.00 4 Joe Eraser 1.50 5 Tim CD 14.99 How do retrieve the data of certain rows such as row 2 and row 5?? I would like then to take the values of the selected rows and write it into a new table somewhere else. Is there a simple method such as (SELECT this row and INSERT INTO a database)?? If anyone has any idea, PLEASE LET ME KNOW. Thanks in Advance. Steve P.S. How do I only retrieve the FIELD NAMES of a table?

    L S 2 Replies Last reply
    0
    • S Steve Lai

      Hi Everyone, I’m using Visual C++6, and I have this question regarding Database programming with Microsoft Access. How do I get a certain row’s field names and it’s values?? For example, let’s say I have an Access table such as: CustID CustName Item Price 1 John Pen 1.99 2 Mike Mirror 5.00 3 Erin Pencils 1.00 4 Joe Eraser 1.50 5 Tim CD 14.99 How do retrieve the data of certain rows such as row 2 and row 5?? I would like then to take the values of the selected rows and write it into a new table somewhere else. Is there a simple method such as (SELECT this row and INSERT INTO a database)?? If anyone has any idea, PLEASE LET ME KNOW. Thanks in Advance. Steve P.S. How do I only retrieve the FIELD NAMES of a table?

      L Offline
      L Offline
      lauren
      wrote on last edited by
      #2

      databases have tables of tables to keep track of what the user databases are all about ... thats how they pull out the right datatypes and values etc etc ... its called metadata and its stored in the system tables ... if you enable the showing of system tables you can query the db for info on the other tables and select whatever you want all well and good but slower than keeping your own table of tables containing just what you need to know ... which is what i do to get stuff like configurable columns in an abitrary data view, etc etc :)

      1 Reply Last reply
      0
      • S Steve Lai

        Hi Everyone, I’m using Visual C++6, and I have this question regarding Database programming with Microsoft Access. How do I get a certain row’s field names and it’s values?? For example, let’s say I have an Access table such as: CustID CustName Item Price 1 John Pen 1.99 2 Mike Mirror 5.00 3 Erin Pencils 1.00 4 Joe Eraser 1.50 5 Tim CD 14.99 How do retrieve the data of certain rows such as row 2 and row 5?? I would like then to take the values of the selected rows and write it into a new table somewhere else. Is there a simple method such as (SELECT this row and INSERT INTO a database)?? If anyone has any idea, PLEASE LET ME KNOW. Thanks in Advance. Steve P.S. How do I only retrieve the FIELD NAMES of a table?

        S Offline
        S Offline
        Steve Driessens
        wrote on last edited by
        #3

        G'day Steve, Check out CDaoTableDef and CDaoFieldInfo. Here's a (very) rough example... CDaoDatabase db; db.Open("DatabaseFileName.mdb", ...other parms...); CDaoTableDef td(&db); td.Open("MyTable"); for(int i = 0; i < td.GetFieldCount(); i++){ CDaoFieldInfo fi; td.GetFieldInfo(i, &fi); // The field's name will be in fi.m_strName; TRACE(_T("Field[%d]: %s\n"), i, fi.m_strName); } td.Close(); db.Close(); Hope this helps, Steve

        S 1 Reply Last reply
        0
        • S Steve Driessens

          G'day Steve, Check out CDaoTableDef and CDaoFieldInfo. Here's a (very) rough example... CDaoDatabase db; db.Open("DatabaseFileName.mdb", ...other parms...); CDaoTableDef td(&db); td.Open("MyTable"); for(int i = 0; i < td.GetFieldCount(); i++){ CDaoFieldInfo fi; td.GetFieldInfo(i, &fi); // The field's name will be in fi.m_strName; TRACE(_T("Field[%d]: %s\n"), i, fi.m_strName); } td.Close(); db.Close(); Hope this helps, Steve

          S Offline
          S Offline
          Steve Driessens
          wrote on last edited by
          #4

          I guess I should have mentioned my exmple (above) is for fetching the field/column names from an existing table in a MS Access database. Steve

          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