倾家荡产悬赏帮我解决问题者 C++连SQL2000 非MFC
我按照网上的教程写了一遍,甚至可以说是完全的抄了一遍
但是很遗憾,我被整疯了:( 错误多达4位数。。。。
共2个文件 见附件~
一个是 头文件 Student.h
二是源文件 Test.cpp
另外一个Student.sql
我疯了
疯了
~
[解决办法]
后面那段改改
m_pRecordset->PutCollect("snum", _variant_t(Stu.num())); // 返回char*进行转换 m_pRecordset->PutCollect("sname", _variant_t(Stu.name().c_str())); // 先设置类型,在赋值 _variant_t vTmp; vTmp.vt = VT_INT; vTmp.intVal = Stu.age(); m_pRecordset->PutCollect("sage", vTmp); m_pRecordset->PutCollect("ssex", _variant_t(Stu.sex().c_str())); m_pRecordset->PutCollect("smajor", _variant_t(Stu.major().c_str())); m_pRecordset->Update(); m_pConnection->Execute(del_cmd.c_str(),NULL,1); m_pRecordset->Close(); } //catch 没指定异常类型 catch(_com_error& e) { cout<<endl; cerr<< "错误:"<<(char*)e.Description()<<endl; } if(m_pConnection->State) m_pConnection->Close(); ::CoUninitialize(); system("pause");