problems with sp_oamethod...

  • using this code:

    declare @fso int , @fso_obj int, @fso_return bit

    EXEC @fso = sp_OACreate  'Scripting.FileSystemObject', @fso_obj OUT

    EXEC @fso = sp_OAMethod  @fso_obj, 'fileexists', @fso_return, @strfilepathname

    (@strfilepathname is a physical path & file name)

    I'm trying to get a return code  other than NULL.

    Have I missed something?

     

  • After the above TSQL try Select @fso and you will have a return value.

    hope this helps

  • well, yes, but it doesn't actually get me to the root of the problem - why would I get a NULL return from a request to create a fso and then either open or create a new file?

    Am I looking at a permissions issue, in which case, what perms do I give out on the folder?

  • well, yes, but it doesn't actually get me to the root of the problem - why would I get a NULL return from a request to create a fso and then either open or create a new file?

    Am I looking at a permissions issue, in which case, what perms do I give out on the folder?

  • partly fixed - missing 'out' in statement!

    however, keep getting '0x80042725' error from this sp...

    EXEC @fsof = sp_OAmethod @fso, 'openTextFile'/*, @fso_return out*/,  @strfilepathname,2

     

    which I have a nasty feeling is the '2' on the end, being sent as a varchar not an int. Any comment about the error?

  • declare @MustCreateFile as bit

    declare @OpenForWriting as tinyint

    Set @OpenForWriting = 2

    Set @MustCreateFile = 1

    EXEC @fsof = sp_OAmethod @fso, 'openTextFile', @fso_return out, @strfilepathname, @OpenForWriting, @MustCreateFile

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply