读书人

代码报了一个error C2678: binary异常

发布时间: 2012-02-27 10:00:22 作者: rapoo

代码报了一个error C2678: binary错误哪位达人帮助下呢?
_variant_t RecordsAffected;
_bstr_t Insert;

CString id;
CString name;
CString password;

GetDlgItem(IDC_EDIT1)->GetWindowText(id);
GetDlgItem(IDC_EDIT2)->GetWindowText(name);
GetDlgItem(IDC_EDIT3)->GetWindowText(password);

Insert = "Insert into best(id, name, password) values('" + id + "','" + name + "', '" + password + "' ) ";
pRst =pConn->Execute(Insert, &RecordsAffected, adCmdText);
AfxMessageBox(_T("添加成功!"));


以上代码在insert这里报了个错,谁能帮我看看呢,谢谢了
e:\vc\test\test0207\test0207\test0207dlg.cpp(181) : error C2678: binary '+' : no operator found which takes a left-hand operand of type 'const char [46]' (or there is no acceptable conversion)
e:\program files\microsoft visual studio 8\vc\atlmfc\include\atlsimpstr.h(666): could be 'ATL::CSimpleStringT<BaseType,t_bMFCDLL> ATL::CSimpleStringT<BaseType,t_bMFCDLL>::operator +(const ATL::CSimpleStringT<BaseType,t_bMFCDLL> &,const ATL::CSimpleStringT<BaseType,t_bMFCDLL> &)' [found using argument-dependent lookup]


[解决办法]
Insert = CString("Insert into best(id, name, password) values('") + id + "','" + name + "', '" + password + "' ) ";

读书人网 >VC/MFC

热点推荐