Article ID: 136994
Article Last Modified on 4/22/2005
APPLIES TO
- Microsoft Foundation Class Library 4.2, when used with:
- Microsoft Visual C++ 1.51
- Microsoft Visual C++ 1.52 Professional Edition
- Microsoft Visual C++ 2.0 Professional Edition
- Microsoft Visual C++ 2.1
- Microsoft Visual C++ 2.2
- Microsoft Visual C++ 4.0 Standard Edition
- Microsoft Visual C++ 4.1 Subscription
- Microsoft Visual C++ 4.2 Enterprise Edition
- Microsoft Visual C++ 4.2 Professional Edition
- Microsoft Visual C++ 5.0 Enterprise Edition
- Microsoft Visual C++ 5.0 Professional Edition
- Microsoft Visual C++ 6.0 Enterprise Edition
- Microsoft Visual C++ 6.0 Professional Edition
- Microsoft Visual C++ 6.0 Standard Edition
- Microsoft SQL Server 6.0 Standard Edition
- Microsoft SQL Server 7.0 Standard Edition
This article was previously published under Q136994
SYMPTOMS
Microsoft SQL Server versions 6.0 and 6.5 support dynasets. To use an updatable dynaset, you must have a unique index on one or more fields in the table. If there is no such index, the recordset will be read only. Also, CRecordset::CanAppend() and CRecordset::CanUpdate() will return FALSE.
STATUS
This behavior is by design.
MORE INFORMATION
If you create a dynaset without specifying a unique index on one or more fields in the table and then try to update or add a record, MFC will throw an exception that says the cursor is read-only. Additionally, you will see the following errors in the MFC Trace output:
In Visual C++ version 1.5x:
In Visual C++ version 2.x and 4.x:
In Visual C++ 5.0, you will see:
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. Here is an example of this syntax:
CREATE TABLE Table1 (cola CHAR(8) PRIMARY KEY NOT NULL, colb CHAR(8))
If you are using the Microsoft SQL Server ODBC driver, version 2.65.0201, that comes with SQL Server version 6.5, MFC will throw an exception that says:
Additionally, you will see the following errors in the MFC Trace output:
Additional query words: CanUpdate CanAppend kbvc151 kbvc152 kbvc200 kbvc210 kbvc220 kbvc400 kbvc500 kbvc600
Keywords: kbtshoot kbdatabase kbprb kbusage KB136994