注册 登录
编程论坛 VC++/MFC

UPdate()错了,却不知道怎么修改

七月的书签 发布于 2015-12-08 18:03, 3064 次点击
void Bookinfmation::OnBnClickedButton1()
{
    // TODO:  在此添加控件通知处理程序代码
    _RecordsetPtr m_pRecordset;
    m_pRecordset.CreateInstance(__uuidof(Recordset));
    MYsql mysql;
    _bstr_t sql = "SELECT * FROM 书籍信息";
    m_pRecordset = mysql.GetRecordSet(sql);
    CString a1,a2,a3,a4,a5,a6;
    GetDlgItem(B_BookName)->GetWindowText(a1);
    GetDlgItem(B_BookID)->GetWindowText(a2);
    GetDlgItem(B_Form)->GetWindowText(a3);
    GetDlgItem(B_Publisher)->GetWindowText(a4);
    GetDlgItem(B_Price)->GetWindowText(a5);
    GetDlgItem(B_Publish_date)->GetWindowText(a6);
    //try
    //{
        if (m_pRecordset != NULL)//&&m_pRecordset->adoEOF)
        {
            m_pRecordset->MoveLast();
            m_pRecordset->AddNew();
            //UpdateData();
            //AfxMessageBox(_T("增加新的一行"));
            m_pRecordset->PutCollect("BookName", (_bstr_t)a1);
            m_pRecordset->PutCollect("BookID", (_bstr_t)a2);
            m_pRecordset->PutCollect("Form", (_bstr_t)a3);
            m_pRecordset->PutCollect("Publisher", (_bstr_t)a4);
            m_pRecordset->PutCollect("Price", (_bstr_t)a5);
            m_pRecordset->PutCollect("Publish_date", (_bstr_t)a6);
            m_pRecordset->Update();        //???错了
            AfxMessageBox(_T("增加成功"));
        }
    //}
    else //catch (_com_error e)
    {
        AfxMessageBox(_T("添加失败"));
    }
}
哪位大大告诉我为什么Update()错了
2 回复
#2
七月的书签2015-12-08 18:20
向数据库中插入信息
#3
七月的书签2015-12-08 18:34
虽然他显示增加成功,但是在数据库中并没有增加信息
1