向各位高手求助(在线等待)

uglystone 2004-08-26 08:21:03
我写了一个将mysql数据库的内容导入Acces数据库的程序.
连接mysql成功且能读出记录的内容。但在向Access发送sql命令时出项异常,以下为其代码
CString ComTexttmp;
_bstr_t ComText;
ComTexttmp.Format("%s","INSERT INTO table()VALUES());
ComText=ComTexttmp.AllocSysString();
m_pRecordset=m_pConnection->Execute(ComText,NULL,adCmdText);
在执行m_pRecordset=m_pConnection->Execute(ComText,NULL,adCmdText)语句时,发生异常
还有在调试完后,调试窗口会出现以下类似的信息
Loaded 'C:\WINDOWS\SYSTEM\OLEAUT32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\OLE32.DLL', no matching symbolic information found.
诚心求教各位大虾帮助
...全文
105 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
uglystone 2004-09-11
  • 打赏
  • 举报
回复
谢谢各位高手
howtotell 2004-08-27
  • 打赏
  • 举报
回复
void CQuery::UpdateDB(CString m_strSQL)
{
_CommandPtr pCommand;
_RecordsetPtr MySet;
pCommand.CreateInstance(__uuidof(Command));
pCommand->ActiveConnection=m_pConnection;
/////////////////////////////////////////////////////////
pCommand->CommandText=(_bstr_t)m_strSQL;
pCommand->CommandType=adCmdText;

try
{
pCommand->Parameters->Refresh();
pCommand->Execute(NULL,NULL,adCmdUnknown);
}
catch(_com_error e)
{
CString errormessage;
errormessage.Format("错误信息:%s",e.ErrorMessage());
AfxMessageBox(errormessage);
}
}
zhangzy2003 2004-08-27
  • 打赏
  • 举报
回复
CString ComTexttmp;

ComTexttmp.Format("%s","INSERT INTO table(???)VALUES(???));
_bstr_t ComText(ComTexttmp);
m_pRecordset=m_pConnection->Execute(ComText,NULL,adCmdText);
看看
Kudeet 2004-08-27
  • 打赏
  • 举报
回复
BSTR bstr = str.AllocSysString();

// Normally, if you pass the BSTR, you will
// need to free the string after returning from the function call.


你加 SysAllocString 函数释放
uglystone 2004-08-27
  • 打赏
  • 举报
回复
是简写的
内存泄漏 2004-08-27
  • 打赏
  • 举报
回复
你写的那个SQL语句,是简写了,还是你程序当中本身就是这样写的啊??

4,011

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧