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. database and structs

database and structs

Scheduled Pinned Locked Moved C / C++ / MFC
questiondatabasesql-serversysadmindata-structures
3 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.
  • G Offline
    G Offline
    ginjikun
    wrote on last edited by
    #1

    hi all! again i need help from the experts :) can someone please help me out in how to access the database (ms sql server 05) and the result (each record) will be placed in a struct. hope someone can help and provide some sample codes. thanks! also another question.. i have a pointer to an array of structs... i would like to create another set (a smaller array) of pointer array based from that struct so i can delete the original array... how can i do this? thanks for all your help! newbie :)

    M 1 Reply Last reply
    0
    • G ginjikun

      hi all! again i need help from the experts :) can someone please help me out in how to access the database (ms sql server 05) and the result (each record) will be placed in a struct. hope someone can help and provide some sample codes. thanks! also another question.. i have a pointer to an array of structs... i would like to create another set (a smaller array) of pointer array based from that struct so i can delete the original array... how can i do this? thanks for all your help! newbie :)

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      You may want to start by deciding what database access technology you're going to use... For Microsoft possibilities, see: Data Access Technologies Road Map[^] Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      G 1 Reply Last reply
      0
      • M Mark Salsbery

        You may want to start by deciding what database access technology you're going to use... For Microsoft possibilities, see: Data Access Technologies Road Map[^] Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        G Offline
        G Offline
        ginjikun
        wrote on last edited by
        #3

        Hi Mark. Tnx for the reply. im going to use ado. i have this sample code already... which returns only a single record. what i am doing is i just get the values of the fields i need and assign it to a variable. szSQL.Format(_T("select * from table where key='101'"); hr = pRS.CreateInstance(__uuidof(Recordset)); if (FAILED(hr)) return false; if (!pRS->adoEOF) { pFields = pRS->Fields; pField = pFields->Item[_T("id")]; _variant_t var = pField->Value; szID = TrimBSTR(var.bstrVal).copy(); pField = pFields->Item[_T("count")]; var = pField->Value; szCnt = TrimBSTR(var.bstrVal).copy(); } now what i am not sure how to do is how to map the result of the query to structs if the return is multiple records. i would like to have the results of the query be stored in an array of structs. do i do the same thing of accessing each fields and creating the struct. i was hoping there is an easier way. thanks! newbie :)

        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