CoInitialize(NULL);
_ConnectionPtr pConn(__uuidof(Connection));

pConn->ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Initial Catalog=qq";
pConn->Open("","","",adConnectUnspecified);
pConn->Execute((_bstr_t)str1,NULL,adCmdText); 
//str1是语句
//str1.Format("select * from user_info where user_id = '%s' and user_pw = '%s'",theInfo->num,theInfo->pw);
//这里如何判断是否插入成功?
pConn.Release();
CoUninitialize();

解决方案 »

  1.   

    你明明是查询,哪里插入了?如果是查询,就用记录住,或者把Execute的返回放到一个记录集里面。
    如果用Execute插入,也可以通过错误捕捉知道成功与否。
    只有update,好像是不知道成功与否的,因为就算没有一条数据被update,也不能认为是出错了。
      

  2.   

    如果这是你说的插入语句的话
    pConn->Execute((_bstr_t)str1,NULL,adCmdText);只要没有返回错误就是插入成功了,没有必要检查的。
      

  3.   

       算法:加入一个标记FLAG,使用测试字符串长度的函数,若为空FLAG=0,否则为1;结果返回字符串的长度