15,979
社区成员
发帖
与我相关
我的任务
分享
void DCUpdate::Onupdate()
{
m_Unumber.GetWindowText(number);
m_Uname.GetWindowText(name);
m_Uage.GetWindowText(age);
m_Usex.GetWindowText(sex);
m_Uclass.GetWindowText(uclass);
m_Umajoy.GetWindowText(majoy);
m_Uhobby.GetWindowText(hobby);
UpdateData(FALSE);
CString c_number; //定义一个变量接收m_Unumber传递的值
m_Unumber.GetWindowText(c_number);
ADO m_Ado;
m_Ado.OnInitADOConn();
m_Ado.m_pConnection->CursorLocation=adUseClient;
CString sql;
sql.Format("select * from infomation where 编号 = '%s'",c_number);
m_Ado.m_pRecordset = m_Ado.OpenRecordset(sql);
try
{
MessageBox(name);
m_Ado.m_pRecordset->PutCollect("姓名",(_bstr_t)name);
m_Ado.m_pRecordset->PutCollect("年龄",(_bstr_t)age);
m_Ado.m_pRecordset->PutCollect("性别",(_bstr_t)sex);
m_Ado.m_pRecordset->PutCollect("专业",(_bstr_t)majoy);
m_Ado.m_pRecordset->PutCollect("班级",(_bstr_t)uclass);
m_Ado.m_pRecordset->PutCollect("爱好",(_bstr_t)hobby);
m_Ado.m_pRecordset->Update();
m_Ado.CloseRecordset();
m_Ado.CloseConn();
MessageBox("修改成功");
EndDialog(0);
}
catch(...)
{
MessageBox("修改失败,请重新修改");
}
DFirst* pDlg = (DFirst*)AfxGetMainWnd();
pDlg->m_Dpart3.m_List.DeleteAllItems();
pDlg->m_Dpart3.OnAddList();
}