-
September 12th, 2003, 08:53 AM
#1
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.
-
September 24th, 2003, 01:20 AM
#2
Try to use pRs->Requery(adCmdUnknown);
See if it works,
Good Luck,
Beatrice
-
September 24th, 2003, 07:22 AM
#3
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
-
September 24th, 2003, 08:42 PM
#4
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
-
September 25th, 2003, 02:28 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|