CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2003
    Location
    Tbilisi, Georgia
    Posts
    36

    CDataGrid Problem

    I have a Problem With CDataGrid

    I fill DataGrid From Access Query (Using ADO) and it works.


    try
    { pConnection.CreateInstance(__uuidof(Connection));
    pRs.CreateInstance(__uuidof(Recordset));
    pRs->Open((_bstr_t)L"Select * from [order details extended]",
    strCnn,adOpenKeyset,adLockOptimistic,adCmdText);
    m_DataGrid.SetRefDataSource( (LPDISPATCH) pRs );
    m_DataGrid.UpdateData();
    m_DataGrid.Refresh();
    }


    I Change Number Field in the Grid. After that I Upadate Recordset object.
    But Joined field (text field in Query from another table) Doesn't change in Grid Until I reopen my Dialog.

    In VB there isn't this problem and changes appear after Update Recordset.


    Waht Can I Do?????
    Please Help
    Thanks.

  2. #2
    Join Date
    Jun 2003
    Location
    Perth - Australia
    Posts
    86
    Try to use pRs->Requery(adCmdUnknown);
    See if it works,
    Good Luck,
    Beatrice

  3. #3
    Join Date
    Jun 2003
    Location
    Tbilisi, Georgia
    Posts
    36
    Thank you Beatrice !

    It works. and I'm hapy


    One question.

    Is there any way to keep the position in Recordset.
    aftre requery?


    I' m sorry for bad English. I' m learning.

    Thanks

  4. #4
    Join Date
    Jun 2003
    Location
    Perth - Australia
    Posts
    86
    Hi vato,
    I'm not so sure, but try the code below and let me know if it works...
    _variant_t pvBookmark;
    pRs->GetBookmark(&pvBookmark); //save position
    pRs->Requery(adCmdUnknown);
    pRs->SetBookmark(pvBookmark); //restore position

  5. #5
    Join Date
    Jun 2003
    Location
    Tbilisi, Georgia
    Posts
    36
    Thank you Beatrice !!!

    I' changed your code like

    _variant_t pvBookmark;
    pvBookmark=pRs->GetBookmark();
    pRs->Requery(adCmdUnknown);
    pRs->Bookmark=pvBookmark;

    And it works. I didn't know what is bookmark at all . Now I see it is very usefull thing.

    Thank you for your 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