最近ADO有个更新, 导致接口的IID不一致, 
建议import 老版本的dll, 这样可以避免这个问题

解决方案 »

  1.   

    加try..catch调试,看下什么错误。
      

  2.   

    加在连接字符串所在位置,还有import时用老版本的.tlb文件,如:
    #import "msado15.tlb" no_namespace rename("EOF", "adoEOF") rename("BOF", "adoBOF")
    把老版本的msado15.tlb文件copy到源程序所在文件夹下编译,这样就可以不用msado15.tlb的绝对路径了。
      

  3.   

    是不是路径不对啊,或者配置了什么系统DSN什么的
    最好把你的ADO链接字符串贴出来看看
      

  4.   

    m_pCon->Open("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=[数据库名字];Data Source=[服务器名字]","","",NULL);
    把上面的服务器名字改成下面的试试看
    Data Source=(local)
      

  5.   

    ado嘛.. 需要ado库. 还需要对应连接db的ole驱动... xp默认 access ,sql2000自带了...
      

  6.   

    是不是没有在Vc中注册Datagird控件啊?
      

  7.   

    There is a by design change in ADO in Windows 7 SP1 that interfaces have new GUIDs as mentioned above. The pattern is that most of all ADO interfaces (say Connection) have new GUIDs while the old GUIDs are assigned to interfaces named xxx_deprecated (say Connection_Deprecated). The reason of this change is mentioned in KB983246:
     
    "Some ADO APIs are platform dependent in ADO 2.7 and later versions. On 64-bit versions of Windows, these ADO APIs process arguments by using a 64-bit data type (such as the LONGLONG data type). However, applications that use these APIs still use the LONG data type. Therefore, you receive a "Type Mismatch" error message when you try to run the macro."
     
    The interfaces with new GUIDs (in Windows 7 SP1) don't have such issue.
     
    This change causes a break that if your application is re-compiled on Windows 7 SP1 and it uses early binding to ADO, it probably doesn't work on down-level OSes, such as Windows 7 RTM, Vista, etc. Please note that this break only happens when the application is re-compiled. Existing applications should run on Windows 7 SP1 without any problems.
     
    If you have to re-compile your application on SP1, there are several workarounds:
     
    1.Request a package of KB983246 and install it on your customers' machines. Re-compiled application should work after the package is installed.
     2.Re-write your application to use later binding to ADO, or use interfaces with name xxx_deprecated.
     3.Keep an old version of ADO typelib (i.e., msado28.tlb) (copy from Windows 7 RTM), then compile your application with the old typelib, instead of the one in your system.
     
    Hope these help.
    ----------------------------------------------------------------------------
    以上是在MS论坛上看到的