void CDlgAdd::OnButtonOk()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_strName.IsEmpty())
{
::MessageBox(NULL, "姓名不能为空!", "添加联系人", MB_OK|MB_ICONINFORMATION|MB_TASKMODAL);
return;
}
CLinkInfo linkInfo;
HRESULT hr = linkInfo.Open();
if (FAILED(hr))
{
::MessageBox(NULL, "打开数据库联系人表失败!", "数据库操作", MB_OK|MB_ICONEXCLAMATION);
return;
}
CString strSQL;
strSQL.Format("insert into LinkInfo(Name, Phone, Email, address, postcode) \
values('%s', '%s', '%s', '%s', '%s')", m_strName, m_strPhone, m_strEmail, m_strAddress, m_strPostcode);
hr = linkInfo.ExecuteSQL((LPTSTR)(LPCTSTR)strSQL);
if(FAILED(hr))
{
::MessageBox(NULL, "插入新行失败", "数据库操作", MB_OK|MB_ICONEXCLAMATION);
return;
}
UpdateData(FALSE);
CDialog::OnOK();
}
OLEDB添加
最新推荐文章于 2024-11-06 11:17:40 发布