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. Access Database Help

Access Database Help

Scheduled Pinned Locked Moved C / C++ / MFC
databasecomhelp
8 Posts 4 Posters 1 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.
  • C Offline
    C Offline
    Cabadam
    wrote on last edited by
    #1

    OK, I have made an app that parses a bunch of files and I have all the data stored into various arrays. I would like to be able to store this information into an Access database. I have no clue where to start on accessing Access and writing information to a database though. If anyone could help me out and point me in the right direction I'd be greatful! Adam cabadam@houston.rr.com

    E 1 Reply Last reply
    0
    • C Cabadam

      OK, I have made an app that parses a bunch of files and I have all the data stored into various arrays. I would like to be able to store this information into an Access database. I have no clue where to start on accessing Access and writing information to a database though. If anyone could help me out and point me in the right direction I'd be greatful! Adam cabadam@houston.rr.com

      E Offline
      E Offline
      Emanuele 0
      wrote on last edited by
      #2

      If you use MFC, CDaoDatabase and CDaoRecordset may help you. With the class wizard add a new CMyDaoRecordset and map the database fields into class members. You find examples on MSDN.

      C 1 Reply Last reply
      0
      • E Emanuele 0

        If you use MFC, CDaoDatabase and CDaoRecordset may help you. With the class wizard add a new CMyDaoRecordset and map the database fields into class members. You find examples on MSDN.

        C Offline
        C Offline
        Cabadam
        wrote on last edited by
        #3

        OK, but it gives me 'unrecognized database format' when creating the class and selecting which database I want to use... I am using Access 2000. Will that not work? Adam cabadam@houston.rr.com

        E D O 3 Replies Last reply
        0
        • C Cabadam

          OK, but it gives me 'unrecognized database format' when creating the class and selecting which database I want to use... I am using Access 2000. Will that not work? Adam cabadam@houston.rr.com

          E Offline
          E Offline
          Emanuele 0
          wrote on last edited by
          #4

          If you use Access 2000 you have to add an instruction in the CYourApp::Initinstance() The instruction is: AfxGetModuleState()->m_dwVersion = 0x0601; This work if you are linking with the MFC DLL. You can take a look at the Q236991 on MSDN for further details.

          1 Reply Last reply
          0
          • C Cabadam

            OK, but it gives me 'unrecognized database format' when creating the class and selecting which database I want to use... I am using Access 2000. Will that not work? Adam cabadam@houston.rr.com

            D Offline
            D Offline
            Doug Garno
            wrote on last edited by
            #5

            Your right, ClassWizard doesn't support Jet 4.0 formatted files. Either create the file in Access 97 or you will have to create the record sets and bind them manually. There is another way to do this and use the generic recordset that is posted in the Database section. That is the way I go because I don't like all the recordset files that are required for each table within the file, source code can get quite large.

            C 1 Reply Last reply
            0
            • D Doug Garno

              Your right, ClassWizard doesn't support Jet 4.0 formatted files. Either create the file in Access 97 or you will have to create the record sets and bind them manually. There is another way to do this and use the generic recordset that is posted in the Database section. That is the way I go because I don't like all the recordset files that are required for each table within the file, source code can get quite large.

              C Offline
              C Offline
              Cabadam
              wrote on last edited by
              #6

              [snip] There is another way to do this and use the generic recordset that is posted in the Database section. [/snip] What do you mean? This is my first venture into doing anythign with databases (at least programatically, I HAVE used Access before :)) I tried to look into the Enroll MFC sample, but it requires some database that you can't download from online (and I can't find my VStudio stuff right now...) Adam cabadam@houston.rr.com

              D 1 Reply Last reply
              0
              • C Cabadam

                [snip] There is another way to do this and use the generic recordset that is posted in the Database section. [/snip] What do you mean? This is my first venture into doing anythign with databases (at least programatically, I HAVE used Access before :)) I tried to look into the Enroll MFC sample, but it requires some database that you can't download from online (and I can't find my VStudio stuff right now...) Adam cabadam@houston.rr.com

                D Offline
                D Offline
                Doug Garno
                wrote on last edited by
                #7

                In the Code Project's General section - Database area, there is an artical called "The CGeneric Database class". What this does is allow you to use the CGeneric recordset without binding the columns the way Class Wizard does. You can either set/get the column data via the calls like GetBool( "Column Name" ); or GetBool( column number ); This is a Dynamic way to use DAO vs the static way that Class Wizard does it. Also if you add new fields to the table, you don't have to rework the code, just add the new Get/Set routines.

                1 Reply Last reply
                0
                • C Cabadam

                  OK, but it gives me 'unrecognized database format' when creating the class and selecting which database I want to use... I am using Access 2000. Will that not work? Adam cabadam@houston.rr.com

                  O Offline
                  O Offline
                  Oscar Vazquez
                  wrote on last edited by
                  #8

                  Visual Studio 6.0 Wizard don't support Access 2000. You must convert to Access 97 or use ODBC instead (Use CRecordset instead of CDaoRecordset)

                  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