Tuesday, July 28, 2009

How to store the file names inside a user specified folder in Access database using visual basic 6.0?

How to store the file names inside a user specified folder in Access database using visual basic 6.0?

How to store the file names inside a user specified folder in Access database using visual basic 6.0?
This is a pretty generic answer but it should point you in the right direction. This is using DAO for the database connection, you could also use ADO to do the same thing. You would use these by setting a reference to the MS DAO or MS Active X Data Objects libraries.





Private Sub UpdateUserInfo()


Dim db As DAO.Database


Dim rs As DAO.Recordset


Dim sFileName As String








Set db = OpenDatabase("C:\database.mdb")


Set rs = db.OpenRecordset("Table")





sFileName = Dir("C:\UserFolder\*.*")





While sFileName %26lt;%26gt; ""


rs.AddNew


rs!FileName = sFileName


rs.Update





'Get next filename in directory


sFileName = Dir


Wend





rs.Close


db.Close





Set rs = Nothing


Set db = Nothing


End Sub


No comments:

Post a Comment