The information in this article applies to:
SUMMARYWith some additional code, dynasets may be used with the MFC 2.51 or 2.52. This sample contains the following components:
To successfully use this code, you must have:
The following files are available for download from the Microsoft Download Center. Click the file names below to download the files: Dynset.exe For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center. MORE INFORMATIONWhat Is a Dynaset?The Visual C++ MFC Encyclopedia in the books online states the following:A dynaset is a recordset with dynamic properties. During its lifetime, a recordset object in dynaset mode (usually called simply a "dynaset") stays synchronized with the data source in the following way. In a multiuser environment, other users may edit or delete records that are in your dynaset or add records to the table your dynaset represents. Records your application updates or deletes from the recordset are reflected in your dynaset. Records that other users add to the table will not be reflected in your dynaset until you rebuild the dynaset by calling its Requery member function. Records that other users delete appear as "holes" in your recordset, marked as "deleted." Other users' editing changes to existing records are reflected in your dynaset as soon as you scroll to the affected record. What Are the Advantages Of Using Dynasets?As mentioned above, dynaset recordsets read directly from the data source for each record fetched in the recordset. Therefore the record can change values between subsequent fetches. There are two additional big advantages which dynasets provide: speed and decreased memory usage. By not using snapshots and using dynasets instead, you don't load the cursor library (ODBCCURS.DLL). The cursor library reads each record for a recordset and stores it into memory as you traverse through the records. Thus, it saves the data for that moment in time. This can slow application performance. The cursor library creates temporary files, which are used for storing the temporary records. This uses more memory and disk space which you wouldn't use if you use dynasets. Lastly, the cursor library traps ODBC API calls before they are sent to the driver and this can slow an application.What Are the Requirements for Using Dynasets?Not all ODBC drivers support MFC dynasets. For example, the ODBC drivers included with Visual C++ version 1.5, 1.51, and 1.52 do not support dynasets. If you use the ODBC drivers provided with the ODBC 2.0 Desktop Driver Pack and the code provided with this sample, you can utilize dynasets for the desktop drivers (Microsoft Access 2.0, FoxPro, and so forth).When using this code, it is important that your ODBC driver support the following:
Look at the help file or other documentation for the ODBC driver you're using to discover whether it supports the items mentioned above. NOTE: The ODBC drivers that come with Visual C++ 1.5 and 1.51 don't support SQLSetPos(). You must be using the ODBC drivers provided with the ODBC 2.0 Driver pack, or something newer. How to Use the CodeA modified version of the ENROLL Step 3 tutorial sample is provided. It demonstrates how to use the dynaset code. To use the code do the following:
Why Are the ODBC 2.1 Components Necessary?The ODBC 2.1 Driver Manager is required to avoid a bug that occurs with the previous versions of the driver manager. If you use the driver manager (ODBC.DLL) included in the ODBC Driver Pack, you will receive an "Invalid Cursor State" error when using dynasets and trying to add a record to a table following an query that produced an empty recordset. In other words, if you open a CRecordset object and the query returns an empty recordset, a subsequent AddNew()/Update() call will cause the error. The ODBC 2.1 driver fixes this problem. The ODBC 2.1 components shipped with Visual C++ 1.52.REFERENCESFor more information about the ODBC functions used, see the ODBC 2.0 Programmer's Reference. This is included in the Visual C++ version 2.0 online books. Additional query words: dynamic dyna set record helpfile
Keywords : kbfile kbprg kbsample kb16bitonly kbDatabase kbMFC kbODBC kbVC |
Last Reviewed: December 12, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |