Question : Why is appendOnly CRecordset readOnly

Hello,

I have an MFC application that connects to an Access DB using ODBC. I use the MFC ODBC interface. Everything was working great, until I switched the option for _MBCS to _UNICODE (with appropriate code changes). Now I get an exception as I try to save to the database because "RecordSet read-only." Is there some problem with ODBC and Unicode? What could be the cause of this change of heart?

Here is my code:
// open the recordset
rs.Open(CRecordset::snapshot, rs.GetDefaultSQL(), CRecordset::appendOnly);
// added to test. I always get the message.
if (!rs.CanAppend()) ::AfxMessageBox(_T("I can not append to this."));

Again, before, when my App was using MBCS, there were no problems at all. The only code I changed in order to get it to compile under UNICODE.

Thanks,
Adeh

Answer : Why is appendOnly CRecordset readOnly

hm ... I'm not sure (since I'm not very experienced with DB-stuff),
but I think the problem is caused by not running 'cursor library'.

In MSDN article Q140598 I found:

>...
>A snapshot recordset relies on the cursor library for
>additions or updates to the database. If the cursor library
>is not loaded, the recordset becomes read-only and does not
>allow additions or updates.
>...

About why cursor library load fails I only found article Q259477
where I found:

>...
>To avoid this problem, do not use ODBC cursors in a
>Unicode environment.
>...

So, as told above I'm no DB-guru, but if the info is correct
I found in MSDN I would read it as 'snapshot recodesets cannot
be used with UNICODE' ...

but maybe I'm wrong  ;o)

ZOPPO


Random Solutions  
 
programming4us programming4us