保存数据到数据库

 

保存数据到数据库

void CWork::GradeSaveToDatabase()
{

    CString sql;
    sql.Format("SELECT * FROM yeya_grade");
    //strTemp = strA.AllocSysString();//strTemp是什么
    ADOCon m_AdoCon;
    m_AdoCon.OnInitADOCon();
    m_AdoCon.m_pRecordset = m_AdoCon.GetRecordSet((_bstr_t)sql);
    m_AdoCon.m_pRecordset->AddNew();
    //数据插入
    m_AdoCon.m_pRecordset->PutCollect("workno", (_bstr_t)m_workno);
    m_AdoCon.m_pRecordset->PutCollect("Appearance", (_bstr_t)m_appear);
    m_AdoCon.m_pRecordset->PutCollect("Name", (_bstr_t)m_name);
    m_AdoCon.m_pRecordset->PutCollect("Number", (_bstr_t)m_number);
    m_AdoCon.m_pRecordset->PutCollect("Grade", (_bstr_t)m_grade);
    m_AdoCon.m_pRecordset->Update();
    //断开与数据库的连接
    m_AdoCon.ExitConnect();
    AfxMessageBox("保存评级成功!");    
}

 

posted @ 2016-01-04 21:04  星雷热忱  阅读(258)  评论(0编辑  收藏  举报