How to Use the DAO Dynaset with Microsoft SQL Server 6.0Last reviewed: October 10, 1997Article ID: Q148917 |
4.00
WINDOWS NT
kbusage kbhowto
The information in this article applies to:
SUMMARYYou can use CDaoRecordset to insert, update, or delete records in a table in a Microsoft SQL Server 6.0 database. There are two ways to do it:
MORE INFORMATION
Using a Direct ODBC Connection in CDaoDatabase::Open()If you create a DAO dynaset without specifying a unique index on one or more fields in the recordset and then try updating or adding a record, MFC DAO will throw an exception and you will see the following errors in the MFC Trace output: AddNew fails with this message: DAO Call Failed. m_pDAORecordset->AddNew() In file daocore.cpp on line 4498 scode = 800A0BD3Error Code = 3027 Source = DAO.Recordset Description = Can't update. Database or object is read-only. Edit() fails with a similar message: DAO Call Failed. m_pDAORecordset->Edit() In file daocore.cpp on line 4525 scode = 800A0BD3Error Code = 3027 Source = DAO.Recordset Description = Can't update. Database or object is read-only.
Using a Linked Table Through a Microsoft Access 7 DatabaseIf you create a DAO dynaset on a linked table in Microsoft Access, the recordset becomes read only if there is no unique identifier specified in Microsoft Access and there is no unique index on some field(s) in the recordset. You will see the same error messages from AddNew or Edit as shown in the previous case. One way to satisfy the requirement for a unique index is to create an index on the primary key. Note that if you use the PRIMARY KEY specification new to SQL Server version 6.0 when creating your tables, you will automatically generate a unique index on the primary key. This syntax is demonstrated here: CREATE TABLE MyTable (column1 CHAR(10) PRIMARY KEY NOT NULL, column2 CHAR(10)) |
Additional reference words: kbinf 4.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |