![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Using ADO with a text file What am I doing wrong? Wouldn't the steps below create text file with a header of "Name", which I could use in turn to query on that column? PS C:\> echo "Name" > data.txt PS C:\> echo "Test" >> data.txt PS C:\> gc data.txt Name Test PS C:\> $adOpenStatic = 3 PS C:\> $adLockOptimistic = 3 PS C:\> $adCmdText = 1 PS C:\> PS C:\> $objConnection = New-Object -comobject ADODB.Connection PS C:\> $objRecordset = New-Object -comobject ADODB.Recordset PS C:\> PS C:\> $objConnection.Open("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = c:\\; Extended Properties = `"Text;HDR=Ye s; FMT=Delimited`"") PS C:\> $objRecordset.Open("Select * from data.txt", $objConnection,$adOpenStatic,$adLockOptimistic,$adCmdText) PS C:\> $objRecordset.MoveFirst() PS C:\> PS C:\> do {$objRecordset.Fields.Item("Name").Value; $objRecordset.MoveNext()} until >> ($objRecordset.EOF -eq $True) >> Exception getting "Item": "Exception calling "get_Item" with "1" argument(s): "Item cannot be found in the collection c orresponding to the requested name or ordinal."" At line:1 char:30 + do {$objRecordset.Fields.Item( <<<< "Name").Value; $objRecordset.MoveNext()} until Exception getting "Item": "Exception calling "get_Item" with "1" argument(s): "Item cannot be found in the collection c orresponding to the requested name or ordinal."" At line:1 char:30 + do {$objRecordset.Fields.Item( <<<< "Name").Value; $objRecordset.MoveNext()} until Exception getting "Item": "Exception calling "get_Item" with "1" argument(s): "Item cannot be found in the collection c orresponding to the requested name or ordinal."" At line:1 char:30 + do {$objRecordset.Fields.Item( <<<< "Name").Value; $objRecordset.MoveNext()} until Exception getting "Item": "Exception calling "get_Item" with "1" argument(s): "Item cannot be found in the collection c orresponding to the requested name or ordinal."" At line:1 char:30 + do {$objRecordset.Fields.Item( <<<< "Name").Value; $objRecordset.MoveNext()} until |
| | #2 (permalink) |
| Guest | Re: Using ADO with a text file > PS C:\> $objConnection.Open("Provider = Microsoft.Jet.OLEDB.4.0; Data > Source = c:\\; Extended Properties = `"Text;HDR=Ye > s; FMT=Delimited`"") I changed the above to HDR=No, and created a Schema.ini: PS C:\> gc data.txt Test PS C:\> $adOpenStatic = 3 PS C:\> $adLockOptimistic = 3 PS C:\> $adCmdText = 1 PS C:\> PS C:\> $objConnection = New-Object -comobject ADODB.Connection PS C:\> $objRecordset = New-Object -comobject ADODB.Recordset PS C:\> gc Schema.ini [data.txt] Col1=Name Text PS C:\> $objConnection.Open("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = c:\\; Extended Properties = `"Text;HDR=No ; FMT=Delimited`"") PS C:\> $objRecordset.Open("Select Name from data.txt", $objConnection,$adOpenStatic,$adLockOptimistic,$adCmdText) PS C:\> $objRecordset.MoveFirst() PS C:\> PS C:\> do {$objRecordset.Fields.Item("Name").Value; $objRecordset.MoveNext()} until >> ($objRecordset.EOF -eq $True) >> ($objRecordset.EOF -eq $True) >> [end] No more error... No output either. Any ideas anyone? |
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do I read a text file and sort text by fixed positions? | Cornelius | PowerShell | 5 | 07-20-2007 06:34 PM |
| find file containing text inside the file | rgrainer | Vista file management | 8 | 05-20-2007 08:05 PM |
| 5536 rar file - 2.58 gb downloaded only 14kb text file inside | =?Utf-8?B?UXVpY2tDaGVlc2U=?= | Vista General | 9 | 09-02-2006 05:57 AM |
| 5536 *.rar 2.58gb file turned into 14kb text file. | =?Utf-8?B?UXVpY2tDaGVlc2U=?= | Vista General | 5 | 08-30-2006 07:23 PM |
| 5536 *.rar file - 2.58gb's but only a 14kb text file inside | =?Utf-8?B?UXVpY2tDaGVlc2U=?= | Vista General | 0 | 08-30-2006 05:32 PM |