Wednesday, May 12, 2004

SQL Server sp_OAGetProperty iterating files collection

So I'll start off actually with a question:
Using SQL Server stored proc sp_OAGetProperty, how can I iterate a file directory to manipulate each file one by one? Currently, I've gotten as far as getting the files collection, but I can't seem to get the sp_OAGetProperty to use Files.Item in any subscripting/indexed way. All FileSystemObject examples use a foreach, which, of course, is not available using sp_OAGetProperty or sp_OAMethod.

1 Comments:

Blogger bronius said...

so far, things like this don't work:

exec @resultcode = sp_OAGetProperty @Folder, 'Files', @Files OUT
If @resultcode <> 0
exec sp_OAGetErrorInfo @oFSO
exec @resultcode = sp_OAGetProperty @Files, 'Item(1).Name', @Filename OUT
If @resultcode <> 0
exec sp_OAGetErrorInfo @oFSO
select @FileName


However, this does:
exec @resultcode = sp_OAGetProperty @Files, 'Item("DirFile.fmt").Name', @Filename OUT


I can't go through the list of files by filename-- I'm trying to iterate the collection by index!

8:57 AM  

Post a Comment

<< Home