[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Using CDaoRecordSet::Requery to refresh records

Posted on 2000-04-02
5
Medium Priority
?
372 Views
Last Modified: 2013-11-20
Hi... I'm getting Recordsets by using a SQL statement in the CDaoRecordset::Open method.... my question is, if I need another SQL statement, is there a way to refresh the records without Closing the recordset and then Opening it again?

Thanks
Skel
0
Comment
Question by:skel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 4

Expert Comment

by:inpras
ID: 2678832
     CDaoDatabase db;
      db.Open("c:\\Temp\\MyDB.mdb", FALSE, FALSE, _T(""));
      CDaoRecordset rs(&db);
      rs.Open(AFX_DAO_USE_DEFAULT_TYPE, "Select * from MyTab", 0);

      db.Execute("UPDATE MyTab SET MyName = 'ABCD'", 0);
      rs.Requery();
??
0
 

Author Comment

by:skel
ID: 2678843
No.... Execute doesn'r return any records.. I meant using SELECT statement

Skel
0
 
LVL 3

Expert Comment

by:_mb_
ID: 2679177
If the recordset is opened, you can't change the SELECT statement. The only way is to change the member variables m_strFilter and/or m_strSort to create new requery-conditions before you call the requery-method.
0
 

Expert Comment

by:z2000
ID: 2679236
If you need another SQL you must close and reopen because recordset is a set of record which you selected ->if not close (to empty buffer)old data and new data is conflicted ). In case use m_strFilter& m_strSort you have to use requery function but that function call Close and Open function (if you debug into Requery you'll see)
0
 
LVL 4

Accepted Solution

by:
inpras earned 150 total points
ID: 2679355
Wel even if execute will not reurn recordset for U I think since it updates table in UR database requery should work. see what I have done for small example

      CDaoDatabase db;
      db.Open("c:\\Temp\\MyDB.mdb", FALSE, FALSE, _T(""));
      CDaoRecordset rs(&db);
      rs.Open(AFX_DAO_USE_DEFAULT_TYPE, "Select * from MyTab", 0);

      db.Execute("UPDATE MyTab SET Name = 'ABCD'", 0);
      rs.Requery();
      rs.MoveLast();
      CString strNo;
      strNo.Format("%d", rs.GetRecordCount());
      AfxMessageBox(strNo);
      db.Execute("INSERT INTO MyTab VALUES('ABCD')", 0);
      rs.Requery();
      rs.MoveLast();
      strNo.Format("%d", rs.GetRecordCount());
      AfxMessageBox(strNo);

Hope this helps
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question