CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2009
    Posts
    20

    Updating DB using MFC

    Hi all,

    I am struggling with one of my system's modules which is I need to edit filed's value in the data source depending on some variables.

    My problem is I stuck with Recordset type because I making the editting via SQL statment and the following which are I done so far:


    CDatabase DBDecaying;


    CString SqlRulesDecaying;

    CString sDriver("MICROSOFT ACCESS DRIVER (*.mdb)");
    CString sDsn;
    CString ssDSN("ODBC;DRIVER={%s};DSN='';DBQ=%s");
    CString sFile("c:\\DB\\db.mdb");

    sDsn.Format(ssDSN, sDriver, sFile);

    DBDecaying.Open(NULL,false,false,sDsn);

    CRecordset RecSetRulesDecaying( &DBDecaying );

    int X=2,Y=3;
    double NewActiLevel = 0;



    SqlRulesDecaying.Format(_T("update Rules set RActiLevel=%f where CNum=%d and RNum=%d"),NewActiLevel,X,Y);


    RecSetRulesDecaying.Open(CRecordset::forwardOnly,SqlRulesDecaying,CRecordset::??????);



    So what I should put insted of ???? I tried (Update,Can Update,..) but I had syntax errors.


    So please any help will be appreciated.

    Best regards.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Updating DB using MFC

    Have you tried the default?

    Also, forwardOnly makes your recordset read only. Try snapshot or dynaset instead.

  3. #3
    Join Date
    Jan 2009
    Posts
    20

    Re: Updating DB using MFC

    Yes I tried dynaset ,snapshot and dynamic and they are not working as well.
    Last edited by hijjawi; October 9th, 2009 at 08:25 AM.

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Updating DB using MFC

    Quote Originally Posted by hijjawi View Post
    Yes I tried dynaset ,snapshot and dynamic and they are not working as well.
    You need to be more specific about what "not working" means.

  5. #5
    Join Date
    Jan 2009
    Posts
    20

    Re: Updating DB using MFC

    I means that no changes occurs on the field.

    please any help

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