我连接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
我想这样读却不的行,请问应该怎么才能读出来??
请问如何将连接字符串读出来放到一个变量中??
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
我想这样读却不的行,请问应该怎么才能读出来??
但是...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 '驅動
通過以上基本可以知道連接的內容
而且读出来的一行每一个字母中间都有空格.
中文读出来却是乱码!!
不過連接用的參數在Cn.Properties都找得到
再加上Cn.Provider其值為SQLOLEDB.1
Set rt = tf.OpenTextFile(lj, , , TristateTrue)