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+MFC console application, zero records inspite of data in file

DAO+MFC console application, zero records inspite of data in file

Scheduled Pinned Locked Moved Database
c++databasesysadminlinuxjson
5 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.
  • S Offline
    S Offline
    samiujan
    wrote on last edited by
    #1

    Hi, In a nutshell: If i kill an MFC+DAO based server application while it is updating records using ctrl-c, the application exits and the database shows 0 records even though, 2 seconds ago, DaoRecordset::RecordCount() was returning 1000. It listens for messages on a socket and updates a RecordSet in table "CallLog". During update, I can see that RecordSet_for_CallLog.GetRecordCount() returns 10, 11 & 12 etc. records as messages are received over the socket, parsed and updated in the dbase. The problem occurs when I close the application midway while it is updating the Recordset. I can see that previous calls to GetRecordCount() were returning 10, 11, 12 etc. but when I open the database file in MS Access, there are no records in the table CallLog. If I open the file in Notepad, I can see the Record data in a jumbled form somewhere. So I guess, for some reason, MS Access garbles up the file while exiting, can someone tell me why? I need to handle this to avoid accidental failure. The main class is not derived from CWinApp. I call the constructor and methods directly in _tmain(). I made the application using the "Win32 Console Application" option in the New project Wizard and later checked the option for MFC support. I have mainly worked in the Win32 API and on Linux, using a comiler from the commandline, so this MFC+DAO mumbo jumbo is pretty confusing. Even Charles Petzold says so :)

    M 1 Reply Last reply
    0
    • S samiujan

      Hi, In a nutshell: If i kill an MFC+DAO based server application while it is updating records using ctrl-c, the application exits and the database shows 0 records even though, 2 seconds ago, DaoRecordset::RecordCount() was returning 1000. It listens for messages on a socket and updates a RecordSet in table "CallLog". During update, I can see that RecordSet_for_CallLog.GetRecordCount() returns 10, 11 & 12 etc. records as messages are received over the socket, parsed and updated in the dbase. The problem occurs when I close the application midway while it is updating the Recordset. I can see that previous calls to GetRecordCount() were returning 10, 11, 12 etc. but when I open the database file in MS Access, there are no records in the table CallLog. If I open the file in Notepad, I can see the Record data in a jumbled form somewhere. So I guess, for some reason, MS Access garbles up the file while exiting, can someone tell me why? I need to handle this to avoid accidental failure. The main class is not derived from CWinApp. I call the constructor and methods directly in _tmain(). I made the application using the "Win32 Console Application" option in the New project Wizard and later checked the option for MFC support. I have mainly worked in the Win32 API and on Linux, using a comiler from the commandline, so this MFC+DAO mumbo jumbo is pretty confusing. Even Charles Petzold says so :)

      M Offline
      M Offline
      markkuk
      wrote on last edited by
      #2

      I guess that the database transaction gets rolled back when the application is aborted.

      S 1 Reply Last reply
      0
      • M markkuk

        I guess that the database transaction gets rolled back when the application is aborted.

        S Offline
        S Offline
        samiujan
        wrote on last edited by
        #3

        thanx for the reply, but if ut got rolled back, i would not see any data, if i open the file in notepad or ultra-edit, i can see my data, login_names and IP's etc. so i guess the prob is not there. thanx anyway!

        M 1 Reply Last reply
        0
        • S samiujan

          thanx for the reply, but if ut got rolled back, i would not see any data, if i open the file in notepad or ultra-edit, i can see my data, login_names and IP's etc. so i guess the prob is not there. thanx anyway!

          M Offline
          M Offline
          markkuk
          wrote on last edited by
          #4

          I don't believe your assumption is correct. Access doesn't necessarily overwrite deleted data in the file, it may just be marked as available space. Then the table will be empty when viewed in Access, but parts of the data may be contained in the .mdb file.

          S 1 Reply Last reply
          0
          • M markkuk

            I don't believe your assumption is correct. Access doesn't necessarily overwrite deleted data in the file, it may just be marked as available space. Then the table will be empty when viewed in Access, but parts of the data may be contained in the .mdb file.

            S Offline
            S Offline
            samiujan
            wrote on last edited by
            #5

            fine, that's ok but before i close it with the cross on the console or thru ctrl-c i see CDaoRecordSet::GetRecordCount() returns 11, 12, 13. When i open the mdb file in access, the table shows zero records. i am not using daoworkspace, is that the problem?

            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