try { CString str; str.Format("select * from login where studentN= '%s' and password = '%d'", m_studentN, m_password); BSTR bstrSQL = str.AllocSysString(); this->m_pRecordset->Open(bstrSQL, (IDispatch*)this->m_pConnection, adOpenDynamic, adLockOptimistic, adCmdText); } catch (_com_error e) { // 显示错误信息 AfxMessageBox(e.Description()); }
写的很明白啊,类型不符啊 CString是动态的TCHAR数组。它是一个完全独立的类,封装了+等操作符和字符串操作方法。 而BSTR是专有格式的字符串,定义为:typedef OLECHAR FAR* BSTR 上面两位告诉了你怎么转换
4,012
社区成员
39,817
社区内容
加载中
试试用AI创作助手写篇文章吧