odbc连接sql server,当无法连接的时候,windows默认(我的机器上)会弹出一个sql server登陆失败的框,然后还会出现一个框来选择登陆服务器的地址和用户名密码什么的,请问高手们如何把这个东东去掉阿……

解决方案 »

  1.   

    http://support.microsoft.com/kb/q150552/
      

  2.   

    With Visual C++ 4.2 and later versions, specify the CDatabase::noOdbcDialog option as the second argument to CDatabase::OpenEx(). This will cause CDatabase::OpenEx() to call SQLDriverConnect with the SQL_DRIVER_NOPROMPT flag. 
      

  3.   

    因为连接需要足够的信息,所以失败,可能是因为需要输入密码和用户名。
    OpenEx()参数中有一项,可以设置为CDatabase::noOdbcDialog,
    CDatabase::noOdbcDialog   Do not display the ODBC connection dialog box, regardless of whether enough connection information is supplied
    也就是说,即使没有足够的信息,也不弹出输入连接信息对话框。