Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ODBC Recordset Problem

89 views
Skip to first unread message

KENNY MAK

unread,
Sep 9, 1998, 3:00:00 AM9/9/98
to
Hello,
I have define the recordset in my class such as
CMyRecordset *mptr;

I my class public function i call the follow :
mptr = new CMyRecordset(&m_db); //mdb is CDatabas
instance
mptr->open(); //I also try to
pass CRecordSet::none ....etc paremeter
But it can't be update and delete.
I have check that mptr->CanUpdate() return FALSE
But i check that mdb.CanUpdate() return TRUE
I also check my database that has all the permission. Why ?

Thank You


Glenn Brude

unread,
Sep 9, 1998, 3:00:00 AM9/9/98
to KENNY MAK
In the CMyRecordset, check that you initialize your
recordset to be updateable:
m_nDefaultType = dynaset;
instead of
m_nDefaultType = snapshot; // readonly

The classwizard asks for this parameter (I think)
when creating the recordset class, and it might be
snapshot by default.

/Glenn

KENNY MAK

unread,
Sep 10, 1998, 3:00:00 AM9/10/98
to
I have set m_nDefaultType = dynaset but still the same

John Frazer

unread,
Sep 10, 1998, 3:00:00 AM9/10/98
to
Alot depends on the SQL behind the recordset.
It may not be updatable.

Alot of that depends on what database, how many tables are
being joined and how they are joined.

Try using SQL to update the database directly (Or use MS-SQL or
ACCESS or something to represent the SQL) and see if the query is
updatable outside of the context of your CRecordset derived object.

JohnF.

KENNY MAK

unread,
Sep 11, 1998, 3:00:00 AM9/11/98
to
I can update the data while i using MS-SQL but prompt recordset
read-only when update
record in the Recordset. Are there any setting require for the MS-SQL or
Visual C++ ?
Give some advice for me and I see whether what's wrong .

John Frazer

unread,
Sep 11, 1998, 3:00:00 AM9/11/98
to
>I can update the data while i using MS-SQL but prompt recordset
>read-only when update
>record in the Recordset. Are there any setting require for the MS-SQL or
>Visual C++ ?
>Give some advice for me and I see whether what's wrong .


Try stepping into Open() particularly where it builds the SQL.. see if
it is doing anything odd... Otherwise I'm out of ideas.

Cheers,
JohnF.


Terry Child

unread,
Sep 16, 1998, 3:00:00 AM9/16/98
to

Glenn Brude wrote in message <35F66719...@aptus.se>...

>In the CMyRecordset, check that you initialize your
>recordset to be updateable:
> m_nDefaultType = dynaset;
>instead of
> m_nDefaultType = snapshot; // readonly


Don't believe everything you read in books (e.g. Blaszczak).
This also depends on the cursor library you are using. With
SQL Server if you use the ODBC cursor library(the MFC default
for snapshots) it will simulate ROWVAL concurrency and allow
updates through the recordset. Try creating a default snapshot
appwiz project, bind a couple of controls and try editing them.
If you set the CDatabase to use driver cursors ( using a parameter of its
open method), snapshot record
sets use static server side cursors in SQL Server which are
readonly. This make things very confusing!

Another annoying thing is that if your SQL contains outer joins
then the SQL server will change a dynaset(keyset) server
cursor into a static readonly one so you have a situation where
a snapshot is updatable but a dynaset isn't!

My brain hurts.

Regards

Terry Child


D.H.

unread,
Sep 16, 1998, 3:00:00 AM9/16/98
to
I just agonized over a similar problem. Maybe my solution will help
you.
I was using ODBC with Access. I kept getting errors when trying to
update
the database inside my program. The recordsets were all dynasets. It
turns
out that my solution was to NOT load the default cursor library when
opening
the database. Look at the last parameter to the database.Open(). The
last
parameter defaults to TRUE, which loads the cursor library. Setting
this
to FALSE solved my problem. Hope it helps you.

--
---------------------------------------------------------
D. W. Hancock Software Development
Pave Tech Inc.

remove ? for correct e-mail. I have been inundated with
too much SPAM.
---------------------------------------------------------

0 new messages