I have a database with 40,000 pdfs in it and I want to go back and get the page counts for each file. What is the most efficient way to do this?
Here's what I have so far (abbreviated):
oAdapt = New OleDbDataAdapter("SELECT idFile, imgFile FROM tblFiles WHERE tFileName LIKE '%.pdf' AND nPages=0", oConn)
oAdapt.Fill(ds, "Files")
For Each dr in ds.Tables("Files").Rows
oPDF = New PdfDocument(dr("imgFile"))
nPages = oPDF.Count
oPDF = Nothing
oCmd.CommandText="UPDATE tblFiles SET nPages=" & nPages & " WHERE idFile=" & dr("idFile")
oCmd.ExecuteNonQuery()
Next
Is there a better way to load the pdf into memory? Or do I have to create a new object for each read?