Page 1 of 1 1
Topic Options
#152976 - 2005-12-06 08:29 PM IDispatch pointers not allowed in expressions! - Error
djmost Offline
Lurker

Registered: 2001-10-16
Posts: 4
Loc: York, PA USA
I run the script listed below. All the records in the test.csv are read and then

ERROR : IDispatch pointers not allowed in expressions!
Script: D:\test\testparse.kix
Line : 28

Here is my code:

$adOpenStatic = 3
$adLockOptimistic = 3
$adCmdText = &1

$objConnection = CreateObject("ADODB.Connection")
$objRecordSet = CreateObject("ADODB.Recordset")
$test = 0

$sPathtoTextFile = "d:\test\"

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

$objRecordset.Open("SELECT * FROM test.csv",
$objConnection,$adOpenStatic,$adLockOptimistic,$adCmdText)

Do
$a = $objRecordset.Fields.Item("First Name")
$b = $objRecordset.Fields.Item("Middle Initial")
$c = $objRecordset.Fields.Item("Last Name")
$d = $objRecordset.Fields.Item("SMTP Address")
$e = $objRecordset.Fields.Item("Location")
$f = $objRecordset.Fields.Item("Department")
$g = $objRecordset.Fields.Item("Comment")
$h = $objRecordset.Fields.Item("Office Phone")
$objRecordset.MoveNext
$test = $test + 1

? $a + " - " $test
Until $objRecordset.EOF

$objRecordSet.Close
$objConnection.Close

Top
#152977 - 2005-12-06 08:45 PM Re: IDispatch pointers not allowed in expressions! - Error
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Try catching the return values from these two method calls ...

$= $objConnection.Open("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + ...

$= $objRecordset.Open("SELECT * FROM test.csv", ...

Top
#152978 - 2005-12-07 11:00 AM Re: IDispatch pointers not allowed in expressions! - Error
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I would also change the line:
Code:

? $a + " - " $test


to:Code:

? $a + " - " $test " (" $objRecordset.EOF ")"

_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.048 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org