Click to See Complete Forum and Search --> : CRecordSet
J.Patricia
June 24th, 1999, 06:10 AM
Hi,
I have created a MFC Appwizard(DLL). I have derived a class from CRecordSet. I haven't implemented bulk data exchange. While I Edit or Delete or AddNew or Update a record assertion failure results. Can you help me to solve this problem.
Thank you.
With regards,
Patricia
sbrandwood
June 24th, 1999, 06:16 AM
What exactly is the error?
I assume you are using a pointer to the recordset.
It could be something to do with the way you are calling your recordset....Is the recordset definitely open (I am not trying to be patronising or anything).
Or it could be something to do with the connection between the code and the database...are you using ODBC?
SB
J.Patricia
June 24th, 1999, 07:00 AM
Hi,
Thank you for your answer. I'm using pointer to CRecordSet and ODBC. I can use the values of the fields using m_ that field name. Also I can access the other member functions such as Open, Close, MoveFirst, etc. But I'm not able to access Edit or Delete or Update member functions. I don't know the reason.
Can you suggest other ways to update a row in a database? Thank you.
With regards,
Patricia
sbrandwood
June 24th, 1999, 07:41 AM
I had a problem like this a while back and was tearing my hair out in frustration until I realised that the ODBC had been initialised as read only. Do you have a CDatabase pointer? Check out the initialisation for this.
I'll look up my code and get back to you.
SB
J.Patricia
June 25th, 1999, 03:53 AM
Hello,
I'm eagerly waiting for your reply. I've not yet solved the problem. Please do help me to solve. Thank you.
With Regards,
Patricia
beaglebuddy
July 2nd, 1999, 05:07 PM
I have run into similar problems. What I found to work is the following:
If you want to insert\update\delete a record, call Open() with the following
parameters:
::Open(CRecordset::dynaset, 0, CRecordset::executeDirect);
Then, if you want to be sure your recordset has the correct permissions to
modify the table, you can call the following CRecordset member functions,
depending on what you need to do:
CanAppend()
CanUpdate()
CanTransact()
storm
May 31st, 2000, 04:45 PM
Your problem may have to do with MS SQL if you are using it.
Check out the following artical from microsoft
Q136994
(you can mail mshelp@mircosoft.com, and put Q136994 in the subject line).
Hiya,
This should solve your problem:
1) Make sure your data source is not read-only.
2) When you use CRecordSet::Open,by default the recordset is updatable unless you specified something else for the "dwoptions" parameter. Check the Help for CRecordSet::Open.
3) To verify #2, use the CRecordSet::CanUpdate command. It will return 1 if the recordset you open is updatable.
This assuming that all other recordset configurations (pointers, etc.) are correct.
Hope this helps.
Sam the Record Man
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.