Link to home
Start Free TrialLog in
Avatar of jfill89
jfill89

asked on

Loop over a directory full of documents

I have the following code:

Set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad")
objBL.ConnectionString = "Provider=SQLOLEDB;Driver={SQL Server};Server=(local);Database=fsbosys;Trusted_Connection=yes;"
objBL.ErrorLogFile = "c:\error.xml"
objBL.Execute "c:\schoolmapping.xml", "E:\inetpub\wwwroot\xmls\local-greatschools-feed-AK.xml"
Set objBL = Nothing

This works great for one document like this "local-greatschools-feed-AK.xml".  But the "E:\inetpub\wwwroot\xmls\" directory has about 100 documents in it and I do not want to have to manually change the code for each document.

How can I read the contents of "E:\inetpub\wwwroot\xmls\" then loop over this code inserting "local-greatschools-feed-AK.xml" for the name of the file?

Thanks

jfill
Avatar of ironwill96
ironwill96

Have you tried using a for each statement to iterate the contents of the directory and then just plug-in the filenames to your statement.

You could do this with a file control.

I will post code for this in a sec.

Nathan
ASKER CERTIFIED SOLUTION
Avatar of ironwill96
ironwill96

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, Even for 50 points (:-}) I'm interested in it's disposition.

.. Alan
I think both provided answers are valid solutions.   So up to you what to do with the points.

Nathan