我是这么写的
      Dim intRet As Long  '返回码
      Dim strDriver As String  '驱动程序
      Dim strAttributes As String  '描述字段
      Dim rc As Integer 'ODBC 函 数 的 返 回 码
      Dim henv As Long 'ODBC 环 境 句 柄
     
      rc = SQLAllocEnv(henv) ' 获 取ODBC 环 境 句 柄      strDriver = "INFORMIX 2.80 32 BIT"  
      strAttributes = "SERVER=" & server.Text & Chr$(0)
      strAttributes = strAttributes & "DESCRIPTION=" & Chr$(0)
      strAttributes = strAttributes & "DSN=" & DsnName.Text & Chr$(0)
      strAttributes = strAttributes & "DATABASE=" & database.Text & Chr$(0)
      strAttributes = strAttributes & "Host=" & hostip.Text & Chr$(0)
      strAttributes = strAttributes & "Service=" & service.Text & Chr$(0)
      strAttributes = strAttributes & "Protocol=" & protocol.Text & Chr$(0)
      strAttributes = strAttributes & "UID=" & username.Text & Chr$(0)
      strAttributes = strAttributes & "PWD=" & pwd.Text & Chr$(0)
       
      intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, strDriver, strAttributes)
      
总是建立失败,是不是我的连接字段有问题,请哪位帮忙解决一下,谢谢了

解决方案 »

  1.   

    你先用ILogin demo测试(Imformix客户端程序自带),查看Services文件中是否定义Imformix的Service,另外用SetNet32工具(Imformix客户端程序自带)定义连接数据库的相关数据
      

  2.   

    我想问一下,host指的是我客户端的ip,还是informix服务器的ip ?
    services文件中的service是我按照服务器端的设置自己加进去的,这样可以吧
    SetNet32中的环境变量那么多,怎么设置?Server Information中的hostname和Host Information中的current host分别指的什么?
      

  3.   

    host是informix服务器的ip,你可以定义任意个hostname,而current host是指当前连接的服务器,用ILogin demo测试,如果不成功会返回一个错误码,用Imformix客户端程序自带的错误查看程序可以了解详细的错误内容
      

  4.   


    谢谢
    server写服务器的机器名字还是"online",曾经有人告诉我写online