- Const adOpenStatic = 3
- Const adLockOptimistic = 3
- Const adCmdText = &H0001
- Set objConnection = CreateObject("ADODB.Connection")
- Set objRecordSet = CreateObject("ADODB.Recordset")
-
- strPathToTextFile = "C:\"
- strFile = "test.txt"
-
- objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
- "Data Source=" & strPathtoTextFile & ";" & _
- "Extended Properties=""text;HDR=NO;FMT=Delimited"""
-
- objRecordSet.Open "Select DISTINCT * FROM " & strFile, _
- objConnection, adOpenStatic, adLockOptimistic, adCmdText
-
- Do Until objRecordSet.EOF
- WScript.Echo objRecordSet.Fields.Item(0).Value
- objRecordSet.MoveNext
- Loop
- objRecordSet.Close
复制代码 网上找的代码,VBS的,通过 ADODB 应该会和谐点吧、、 |