老兄它提示ODBC有错误,那你能不能换一种数据库的连接方法试试呢?
不用dsn连接文件,改用连接字符串串试试。还有我的几点看法:
在你的那个中:Public Function GetRecordset _
                   ( _
                     SQL As String, _
                     Optional CursorType As CursorTypeEnum = 1, _
                     Optional LockType As LockTypeEnum = 1 _
                    ) As ADODB.Recordset
            
1.远程数据服务,当用于客户端Recordset 对象时,只能将 CursorType 属性设置为 adOpenStatic。
2.远程数据服务,当在客户端的Recordset 对象上使用时,LockType 属性只能设置为 adLockOptimisticBatch。

解决方案 »

  1.   

    to chenyu5188:
    我試著用過ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=database;Data Source=dataserver;username=username;password=password"不行。關于游標是我在測試后忘記改了﹐正常的代碼是這樣
    Public Function GetRecordset _
                ( _
                SQL As String, _            
                Optional CursorType As CursorTypeEnum = adOpenUnspecified, _
                Optional LockType As LockTypeEnum = adLockUnspecified, _
                Optional CommandType As CommandTypeEnum = adCmdUnspecified _
                ) As ADODB.Recordset
        On Error GoTo ErrH
        Dim rs As New ADODB.Recordset
        
        If mrpConn.State = adStateClosed Then ConnectServer
        
        rs.CursorLocation = adUseClient
        rs.Open SQL, mrpConn, CursorType, LockType, CommandType
        Set GetRecordset = rs
        Exit Function
    ErrH:
        Set rs = Nothing
        libErrHandler ModuleName, "GetRecordset:" + SQL
        Set GetRecordset = Nothing
        
    End Function游標和鎖定方式沒有問題﹐這個所謂的架构其實就是把用戶所有對數据庫的操作集中到一台机器﹐由它統一向數据庫服務器發出訪問需求。在游標上我以前做過測試這樣應該是可以的。
      

  2.   

    另外如果是游標的問題錯誤提示也不應該是“[Microsoft][ODBC驱动程序管理员]找不到资料来源名称且未指定预设的驱动程序”
      

  3.   

    to hsn1982:
    如果是連接語句有問題﹐會有相應的錯誤提示。現在看到的錯誤提示是由錯誤代碼處理函數(libErrHandler )顯示出來的﹐已經注名了是在GetRecordset中發生的錯誤。
      

  4.   


    在每次编译后需要在测试服务器上复制并注册 .dll。传送到业务对象的 DSN 应该是服务器上的“系统 DSN”。如果它不存在或没有正确设置,那么用户组件将失败。最好用其它的 ODBC 应用程序来测试服务器上的 DSN 以确保正确设置 DSN。