CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: CRecordSet

  1. #1
    Join Date
    Jun 1999
    Posts
    4

    CRecordSet

    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

  2. #2
    Join Date
    May 1999
    Posts
    42

    Re: CRecordSet

    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


  3. #3
    Join Date
    Jun 1999
    Posts
    4

    Re: CRecordSet

    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

  4. #4
    Join Date
    May 1999
    Posts
    42

    Re: CRecordSet

    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


  5. #5
    Join Date
    Jun 1999
    Posts
    4

    Re: CRecordSet

    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

  6. #6
    Join Date
    Apr 1999
    Location
    Scottsdale, Arizona
    Posts
    28

    Re: CRecordSet

    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:ynaset, 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()



  7. #7
    Join Date
    Jun 1999
    Location
    Vancouver, Canada
    Posts
    19

    Re: CRecordSet

    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 [email protected], and put Q136994 in the subject line).




  8. #8
    Guest

    Re: CRecordSet

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured