我在一个登陆界面里进行注册时,向数据库插入新记录出错了,请问如何解决:
该数据表包括 uid(这是 identity  的),uname,upassword,unation ,ucity。对应对话框的Edit控件的变量为:
(其中uid不用输入,由数据库自动添加)
uname  ==>> m_strID
upassword ==> m_strPW
unation ==>> m_strNation
ucity ==>> m_strCityCRecordSet类 为: CLoginSet
对话框类为:      CRegisterDlg
下面是我的插入过程:void LoginDlg::OnRegister() 
{
// TODO: Add your control notification handler code here
CDatabase ds;
CLoginSet *pLgnSet;
pLgnSet = new CLoginSet(&ds);
CRegisterDlg regDlg; if(regDlg.DoModal() == IDOK){
if(pLgnSet->IsOpen()) pLgnSet->Close();
if(!pLgnSet->Open()) regDlg.MessageBox("Can not open the database!");
if(pLgnSet->CanAppend()){
try{
pLgnSet->AddNew();
pLgnSet->m_uname = regDlg.m_strID;
pLgnSet->m_upassword = regDlg.m_strPW;
pLgnSet->m_unation = regDlg.m_strNation;
pLgnSet->m_ucity = regDlg.m_strCity;
if(!pLgnSet->IsBOF())
pLgnSet->MoveFirst();
pLgnSet->Requery();
pLgnSet->Update();
}
catch(CDBException e){
e.ReportError();
}
AfxMessageBox("Register sucessfully!");
}
else
AfxMessageBox("The database can not Append()!");
}
}