CString sql;
CDaoDatabase* m_pDB;
//...   得到m_pDB,没有问题
ASSERT (m_pDB); CDaoRecordset rs(m_pDB);

sql = "SELECT * FROM [money] WHERE name='" + m_strName;
sql += "'"; try
{
rs.Open (dbOpenDynaset, sql);
if (!rs.IsEOF ()) //Already exists
{
MessageBox (" 本记录已经存在,请重新填写。 ",
"错误!", MB_OK | MB_ICONEXCLAMATION);
rs.Close (); return;
}
else
{
COleVariant covName, covRatio;
covName.vt = VT_BSTR;
covName.pbVal = (PUCHAR)m_strName.GetBuffer (m_strName.GetLength ());
covRatio.vt = VT_R4;
covRatio.fltVal = (float)atof (strRatio.GetBuffer (strRatio.GetLength ()));
rs.AddNew (); 
rs.SetFieldValue ("name", covName);
rs.SetFieldValue ("ratio", covRatio);
rs.Update ();
rs.Close ();
}   
}
catch (CDaoException *e)
{
TCHAR szCause[255];
CString strFormatted = _T("无法读取数据表money! \n");

e->GetErrorMessage(szCause, 255);
strFormatted += szCause;
AfxMessageBox(strFormatted, MB_OK | MB_ICONEXCLAMATION);

e->Delete ();
} m_pDB = NULL;