MovePrev() throwing 265926 error code (End Of RowsSet).
-
Hi In my MFC application i am reading and MDB file using CCommand as follows:
CDBPropSet cdbPropset;
CCommand , CRowset> cCommand;
cdbPropset.AddProperty(DBPROP_CANSCROLLBACKWARDS, true);
cCommand.Open(m_pSessionManager->m_Session, csSQLQuery);
hr = cCommand.MoveFirst();
//insert some thing.
hr = cCommand.MovePrev();In above code MovePrev() always throwing 265926 error code which is End Of RowsSet. Can any on let me know whats wrong in my code.? Why record is not moving to previous row? Thanks for the help.
You call
MoveFirst()
which sets the pointer to the first record. A following call toMovePrev()
will of course fail withDB_S_ENDOFROWSET
because the pointer is already at the first position which is the end of the row set for backward scrolling operations. I can't help further without knowing what you finally want to achieve (why do you want to scroll backwards). But moving backwards when already at the first position makes no sense. -
You call
MoveFirst()
which sets the pointer to the first record. A following call toMovePrev()
will of course fail withDB_S_ENDOFROWSET
because the pointer is already at the first position which is the end of the row set for backward scrolling operations. I can't help further without knowing what you finally want to achieve (why do you want to scroll backwards). But moving backwards when already at the first position makes no sense.I am inserting some values in MDB. Lets say, after inserting 10 values, the pointer will be at 11 row since every time after inserting i will call movenext(). Now while inserting 11th value, i want to go to 10th row and delete the value in 10th row for which i need to call moveprev().
-
I am inserting some values in MDB. Lets say, after inserting 10 values, the pointer will be at 11 row since every time after inserting i will call movenext(). Now while inserting 11th value, i want to go to 10th row and delete the value in 10th row for which i need to call moveprev().
This was not really clear from your question. To know what happens you should at least show some example lines. Note also that the behaviour depends on the used cursor type. A common method to identify rows that has been inserted is using bookmarks which can be used later to select the row. Maybe you should also rethink your design because inserting a row and deleting it within the same session makes no sense. Your code should detect that in advance so that there is no need to insert that row at all.
-
This was not really clear from your question. To know what happens you should at least show some example lines. Note also that the behaviour depends on the used cursor type. A common method to identify rows that has been inserted is using bookmarks which can be used later to select the row. Maybe you should also rethink your design because inserting a row and deleting it within the same session makes no sense. Your code should detect that in advance so that there is no need to insert that row at all.
That was just an example i have given but not the exact requirement. But at any cost i want to perform this MovePrev() operation once at the end for my project requirement. But some how its failing (returning error code) even after setting the property on CBPropSet.
CDBPropSet cdbPropset(DBPROPSET_ROWSET);
cdbPropset.AddProperty(DBPROP_CANSCROLLBACKWARDS, true);CCommand ,CRowset> cCommand;
hr = cCommand.Open(m_Session, csSQLQuery, &cdbPropset);
if( SUCCEEDED( hr ) )
{
hr = cCommand.MoveFirst();for(int i = 0; i < 3; i++)
{
cCommand.m_labelvalueindex = 1;
cCommand.m_labellinenumber = 2;hr = cCommand.Insert();
hr = cCommand.MoveNext();
}
//Here i want to perform moveprev().
cCommand.Close();
}After the for loop i just want to perform Moveprev(). Can you tell me any wrong in above code.?
-
That was just an example i have given but not the exact requirement. But at any cost i want to perform this MovePrev() operation once at the end for my project requirement. But some how its failing (returning error code) even after setting the property on CBPropSet.
CDBPropSet cdbPropset(DBPROPSET_ROWSET);
cdbPropset.AddProperty(DBPROP_CANSCROLLBACKWARDS, true);CCommand ,CRowset> cCommand;
hr = cCommand.Open(m_Session, csSQLQuery, &cdbPropset);
if( SUCCEEDED( hr ) )
{
hr = cCommand.MoveFirst();for(int i = 0; i < 3; i++)
{
cCommand.m_labelvalueindex = 1;
cCommand.m_labellinenumber = 2;hr = cCommand.Insert();
hr = cCommand.MoveNext();
}
//Here i want to perform moveprev().
cCommand.Close();
}After the for loop i just want to perform Moveprev(). Can you tell me any wrong in above code.?
As already noted: Use bookmarks (see Using Bookmarks[^]). Set the bookmark when at the position you want to access later where you can then use
MoveToBookmark()
. -
As already noted: Use bookmarks (see Using Bookmarks[^]). Set the bookmark when at the position you want to access later where you can then use
MoveToBookmark()
.Since my command class is CRowSet, there is no SetBookMark() method on it.
-
Since my command class is CRowSet, there is no SetBookMark() method on it.
It is a
CAccessor
member. -
That was just an example i have given but not the exact requirement. But at any cost i want to perform this MovePrev() operation once at the end for my project requirement. But some how its failing (returning error code) even after setting the property on CBPropSet.
CDBPropSet cdbPropset(DBPROPSET_ROWSET);
cdbPropset.AddProperty(DBPROP_CANSCROLLBACKWARDS, true);CCommand ,CRowset> cCommand;
hr = cCommand.Open(m_Session, csSQLQuery, &cdbPropset);
if( SUCCEEDED( hr ) )
{
hr = cCommand.MoveFirst();for(int i = 0; i < 3; i++)
{
cCommand.m_labelvalueindex = 1;
cCommand.m_labellinenumber = 2;hr = cCommand.Insert();
hr = cCommand.MoveNext();
}
//Here i want to perform moveprev().
cCommand.Close();
}After the for loop i just want to perform Moveprev(). Can you tell me any wrong in above code.?
Sampath579 wrote:
Can you tell me any wrong in above code.?
Is there a need to call
MoveNext()
? Thefor()
loop is just inserting 3 rows, correct?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Sampath579 wrote:
Can you tell me any wrong in above code.?
Is there a need to call
MoveNext()
? Thefor()
loop is just inserting 3 rows, correct?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
If I don't call the movenext then pointer will be at one row and the data may overwrite. In my requirement I want to moveprev one step and delete it.
-
Hi In my MFC application i am reading and MDB file using CCommand as follows:
CDBPropSet cdbPropset;
CCommand , CRowset> cCommand;
cdbPropset.AddProperty(DBPROP_CANSCROLLBACKWARDS, true);
cCommand.Open(m_pSessionManager->m_Session, csSQLQuery);
hr = cCommand.MoveFirst();
//insert some thing.
hr = cCommand.MovePrev();In above code MovePrev() always throwing 265926 error code which is End Of RowsSet. Can any on let me know whats wrong in my code.? Why record is not moving to previous row? Thanks for the help.
I believe Jochen was spot on with his very first remark. The documentation of CRowset::MoveFirst | Microsoft Docs[^] clearly states that
Quote:
Calls IRowset::RestartPosition to reposition the next-fetch location to the initial position (the position that was the next-fetch location when the rowset was created) and retrieves the initial row.
(emphasis mine) In other words, your next Fetch would return the initial row at that time, no matter how many changes you made to the table in between the Move and the Fetch! Looks like you should trust your error message and change your code accordingly. P.S.: I just realized that it may still be considered ambiguous. However, you have to consider if (or why) the insertion of rows should affect the current Fetch position. The Insert command documentation does not indicate that it affects the Fetch position. If it would, shouldn't it say as much?
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
-
If I don't call the movenext then pointer will be at one row and the data may overwrite. In my requirement I want to moveprev one step and delete it.
Sampath579 wrote:
If I don't call the movenext then pointer will be at one row and the data may overwrite.
How have you verified this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Since my command class is CRowSet, there is no SetBookMark() method on it.
Small correction in my question. The error code is -2147217837.
-
I believe Jochen was spot on with his very first remark. The documentation of CRowset::MoveFirst | Microsoft Docs[^] clearly states that
Quote:
Calls IRowset::RestartPosition to reposition the next-fetch location to the initial position (the position that was the next-fetch location when the rowset was created) and retrieves the initial row.
(emphasis mine) In other words, your next Fetch would return the initial row at that time, no matter how many changes you made to the table in between the Move and the Fetch! Looks like you should trust your error message and change your code accordingly. P.S.: I just realized that it may still be considered ambiguous. However, you have to consider if (or why) the insertion of rows should affect the current Fetch position. The Insert command documentation does not indicate that it affects the Fetch position. If it would, shouldn't it say as much?
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
It does not work. Any other way of moving to previous record. MovePrev() throwing -2147217837 error code. I definitely need to go and get the data from MovePrev().
-
It does not work. Any other way of moving to previous record. MovePrev() throwing -2147217837 error code. I definitely need to go and get the data from MovePrev().
QASolved, a prominent name among the best & most affordable QuickBooks ProAdvisor Assistant in the US offers cost-efficient <QuickBooks ProAdvisor Support (877) 263-2742 specifically designed to cater to small businesses within the US region. Call us today to get in touch with a QB ProAdvisor in your area.