Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Using ADO to read a text file

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 11-08-2006   #1 (permalink)
Marco Shaw
Guest


 

Using ADO to read a text file

Trying the following PSH code:

$adOpenStatic = 3
$adLockOptimistic = 3

$objConnection = New-Object -comobject ADODB.Connection
$objRecordset = New-Object -comobject ADODB.Recordset

$objConnection.Open("Provider = Microsoft.Jet.OLEDB.4.0; Data Source =
c:\test.2; Extended Properties = text; HDR=YES; FMT=Delimited")
$objRecordset.Open("Select * from test.2",
$objConnection,$adOpenStatic,$adLockOptimistic)

$objRecordset.MoveFirst()

do {$objRecordset.Fields.Item("Name").Value; $objRecordset.MoveNext()} until
($objRecordset.EOF -eq $True)

$objRecordset.Close()
$objConnection.Close()

PSH errs out here:
PS C:\> $objConnection.Open("Provider = Microsoft.Jet.OLEDB.4.0; Data Source
= c:\test.2; Extended Properties = text; HDR=YES; FMT=Delimited")
Exception calling "Open" with "4" argument(s): "Could not find installable
ISAM."
At line:1 char:20
+ $objConnection.Open( <<<< "Provider = Microsoft.Jet.OLEDB.4.0; Data Source
= c:\test.2; Extended Properties = text; HDR=YES; FMT=Delimited")

What's an "ISAM"?




My System SpecsSystem Spec
Old 11-08-2006   #2 (permalink)
Roman Kuzmin
Guest


 

Re: Using ADO to read a text file

Try this:

$objConnection.Open('Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\temp;Extended Properties="text;HDR=YES;FMT=Delimited"')

--
Thanks,
Roman


My System SpecsSystem Spec
Old 11-08-2006   #3 (permalink)
/\\/\\o\\/\\/ [MVP]
Guest


 

Re: Using ADO to read a text file


"Roman Kuzmin" <z@z.z> wrote in message
news:uJGAXE0AHHA.4992@TK2MSFTNGP03.phx.gbl...
> Try this:
>
> $objConnection.Open('Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=c:\temp;Extended Properties="text;HDR=YES;FMT=Delimited"')
>
> --
> Thanks,
> Roman

as an addition to Roman's anwer

I have some more information and examples about opening and using textfiles
with ADO (and also for using it with other providers like SQL Excel )on my
blog :

that can help you getting started with this

CSV :
http://mow001.blogspot.com/2006/03/w...-part-one.html
http://mow001.blogspot.com/2006/03/w...-part-two.html

Fixed Lenght :

http://mow001.blogspot.com/2006/07/w...881469178.html

Greetings /\/\o\/\/


My System SpecsSystem Spec
Old 11-09-2006   #4 (permalink)
Jacques Barathon [MS]
Guest


 

Re: Using ADO to read a text file

"/\/\o\/\/ [MVP]" <mow001@hotmail.NoSpam> wrote in message
news:%23UKSAP3AHHA.1224@TK2MSFTNGP04.phx.gbl...
<...>
> Fixed Lenght :


Did you mean "Fixed Count"? :-)

Jacques

My System SpecsSystem Spec
Closed Thread
Update your Vista Drivers Update Your Drivers Now!!

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Howto: Add lines of text from a specific point in a text file.. Daz VB Script 13 06-24-2008 10:55 AM
How to read and write a text file? Jirong Hu VB Script 1 06-14-2008 03:31 PM
Read a huge text file from bottom up Hayato Iriumi PowerShell 4 04-25-2008 02:44 PM
How do I read a text file and sort text by fixed positions? Cornelius PowerShell 5 07-20-2007 06:34 PM
Read mails in plain text Simon Vista mail 3 07-03-2006 01:06 PM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51