当uuid中包含00时,感觉无法实现操作,不报错,但无动作。
代码如下,当uuid中不包含00时,可以正常执行,但包含00时,无异常但实际中没有删除数据,求指点,谢谢了!!!
bool  _DB_DeletePatientInfo( CString t_sPatLogicID )
{
//判断数据库状态,如果没有连接,则连接
if ( !m_bDataBaseConnected )
{
if ( !_DB_GetInTouchDatabase() )
{
return false;
}
} //如果当前记录是打开状态,则先关闭并设为NULL
if ( m_pRecordset->State )
{
m_pRecordset->Close();
} //查找病人
CString tmp ("select * from Patient where PatLogicID = 0x");      //PatLogicID为uuid
int i;
for ( i = 0; i < 16; ++i )
{
CString t_sAdd;
t_sAdd.Format( "%x", (BYTE)t_sPatLogicID.GetAt(i) );
if ( t_sAdd.GetLength() == 1 )
{
t_sAdd = "0" + t_sAdd;
}
tmp = tmp + t_sAdd;
} _bstr_t strSQL = tmp; if ( m_pRecordset->State ) //如果当前记录是打开状态,则先关闭并设为NULL
{
m_pRecordset->Close();
} try
{                  
m_pRecordset->Open(_bstr_t (strSQL),  
_variant_t((IDispatch *)m_pConnection, true),
adOpenStatic,
adLockOptimistic,
adCmdText);
}
catch(_com_error e)
{
AfxMessageBox(_T("SearchSampleInfo: 无法上传到数据库"));
m_pConnection->Close();
return false;
} _variant_t TheValue;
TheValue = m_pRecordset->GetCollect("PatNO");
if ( TheValue.vt != VT_NULL )
{
CString PatNO = TheValue;       //这里可以正常读出病人的身份证号码,表明 m_pRecordset中可以得到数据
} //删除病人
if( m_pRecordset->adoEOF )
{
AfxMessageBox(_T("当前没有病人被选中"));
return false;
} try    //这里没有报错,都正常执行的,但是实际中数据没有被删除。
{
m_pRecordset->Delete(adAffectCurrent);
m_pRecordset->Update();
}
catch(_com_error e)
{
AfxMessageBox(_T("SearchSampleInfo: 无法上传到数据库"));
m_pConnection->Close();
return false;
} return true;