Home > Software engineering >  M_pRecordset -> Delete (adAffectCurrent) what went wrong
M_pRecordset -> Delete (adAffectCurrent) what went wrong

Time:10-11

 STRSQL="select * from flow_info_tb order by flow_ID";//the default ascending 
//query flow_info_tb all records in the
M_pRecordset. CreateInstance (__uuidof (you));
Try
{
M_pRecordset - & gt; Open ((_variant_t) STRSQL,
TheApp. M_pConnection. GetInterfacePtr (),
AdOpenDynamic,
AdLockOptimistic,
AdCmdText);
}
Catch _com_error * (e)
{
AfxMessageBox (e - & gt; ErrorMessage ());
}

Try
{
If (m_pRecordset - & gt; BOF)//no record
{
M_pRecordset - & gt; Close();
M_pRecordset=NULL;
return;
}
The else//recorded
{
M_pRecordset - & gt; MoveFirst ();

BYTE equip.
while(! M_pRecordset - & gt; AdoEOF)
{
//flow_info_tb several fields in the table, one is flow_ID, string type n1 n2 - n3 format
. ;//the data processing part
Equip=n1;//processing get n1
If (equip==1)//if n1 is equal to 1 to delete the record
{
M_pRecordset - & gt; Delete (adAffectCurrent);//sorted recordset records deleted, this error!
M_pRecordset - & gt; The Update ();
}
M_pRecordset - & gt; MoveNext ();
}
}
}
Catch _com_error * (e)
{
AfxMessageBox (e - & gt; ErrorMessage ());
}
M_pRecordset - & gt; Close();
M_pRecordset=NULL;


M_pRecordset - & gt; Delete (adAffectCurrent); Error
(1) and connect to the database user permissions related procedures? Has allowed to insert in the permissions, change, update, delete, select,
2. With the Open function of adOpenDynamic, adLockOptimistic parameters?
3. Related to query the order by?


CodePudding user response:

To carry out your SQL statements in the database, see whether it is right

CodePudding user response:

reference 1st floor oyljerry response:
to carry out your SQL statements in the database, see whether it is right


Right is the query flow_info_tb all records in the table, and press flow_ID ascending,

Use a method to solve the trouble now,
In the original delete individual records the location of the execution as the Open function delete above,

CodePudding user response:

Only perform a try, don't cycle

CodePudding user response:

Before you delete, check whether the record pointer EOF or BOF
  • Related