我连接SQL2000用的是UDL文件进行连接串的记录.
请问如何将连接字符串读出来放到一个变量中??
Set rt = tf.OpenTextFile(lj)
    While Not rt.AtEndOfStream
    If InStr(1, Trim(rt.ReadLine), "Provider", 0) = 找到匹配字符串的位置 Then
    ljz = Trim(rt.ReadLine)
    Debug.Print ljz
    End If
    Wend
 rt.Close
我想这样读却不的行,请问应该怎么才能读出来??

解决方案 »

  1.   

    If InStr(1, Trim(rt.ReadLine), "Provider", 0) <> 0 Then
      

  2.   

    直接得出連接字符串的方法我不知道
    但是...Dim Cn As New ADODB.Connection
    通過UDL連接數據庫後
    可以用以下方法得到你要的幾個主要參數值
       Debug.Print Cn.Properties("Password").Value  '密碼
       Debug.Print Cn.Properties("User ID").Value   '用戶
       Debug.Print Cn.Properties("Initial Catalog").Value  '數據庫
       Debug.Print Cn.Properties("Data Source").Value  '數據源,即:數據庫服務器名稱
       Debug.Print Cn.Properties("Provider Friendly Name").Value  '驅動
    通過以上基本可以知道連接的內容
      

  3.   

    哦,为什么UDL可以用TEXT打开可是读却不能读出来呢??
    而且读出来的一行每一个字母中间都有空格.
    中文读出来却是乱码!!
      

  4.   

    直接以TXT的方法打開我還試過
    不過連接用的參數在Cn.Properties都找得到
    再加上Cn.Provider其值為SQLOLEDB.1
      

  5.   

    UDL文件是Unicode格式的文本文件。
      

  6.   

    改成这样就可了
    Set rt = tf.OpenTextFile(lj, , , TristateTrue)