Sign in to follow this  
Followers 0
litlmike

ADODB Connection $objRecordset.Open Action Fails

3 posts in this topic

"The requested action with this object has failed"

I get this message with the following code. I looked here for an example, and I can't find any place where i made a mistake (http://www.microsoft.com/technet/scriptcen...5/tips0607.mspx)

Suggestions please. TIA

Const $adOpenStatic = 3
Const $adLockOptimistic = 3
Const $adCmdText = 0x0001 ;  =&H0001
Global $sFilePath1 = FileGetShortName(@ScriptDir & "\Stats.xls")
Global $s_Tablename = "[Sheet1$]" ; 

    $objConnection = ObjCreate("ADODB.Connection")
    $objRecordSet = ObjCreate("ADODB.Recordset")

    $objConnection.Open ("Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source="&$sFilePath1&";" & _
                "Extended Properties=""Excel 8.0;HDR=Yes;"";")
    
$objRecordset.Open ("Select * FROM [Sheet1$] Where SiteName = Aventouras", $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText)

Share this post


Link to post
Share on other sites



You should add a custom COM error handler to aid in debugging,

Look in the helpfile under Obj/Com Reference then the subtopic COM Error Handling

That should give you more info about the root cause of your error.

Share this post


Link to post
Share on other sites

You should add a custom COM error handler to aid in debugging,

Look in the helpfile under Obj/Com Reference then the subtopic COM Error Handling

That should give you more info about the root cause of your error.

Ah hah! That is what that stuff means. Okay so I stole this from one of ptrex's posts and here is the new code. I got the following errors, which didn't help me too much, but I figured out what the problem was either way.

This line should have read (it was missing the ' )

$objRecordset.Open ("Select * FROM [Sheet1$] Where SiteName = 'Aventouras'", $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText)oÝ÷ Ú«¨µå{^­Ç©µçZ㮺+ßw«­×¬r¸©¶*'Ãh½©nz¯zwè®Þ¢¹¨­êÞªè«yÚZ­©µêìzºðw^±Êâ¦Ø¨ã¢zºçºfÞ®+

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0