When attempting to read all documents from a Lotus Notes database using Visual Basic through COM, I’ve noticed issues where databases do not list the number of documents they have correctly.
In one case, I have an NSF that is an email database that lists only 80 documents that actually contains over 1500 documents. The AllDocuments property of the database will only list 80, but the AllEntries property of the All Documents view lists a more accurate amount.
Is there any way to get a database to reindex or recount the number of documents it contains while the database is disconnected from it’s Domino server? In this case, would using a NotesDocumentCollection generated from a NotesDatabase Search method using @ALL as the formula be a good idea?
Subject: Database properties lists fewer documents than in database
It sounds like you have some other issue going on. The db.alldocuments does represent / should return the collection of all documents in the database.
Your view entry represents a row in a view. If the view is categorized and the document shows up in multiple categorys, this could be why your count is higher with a view entry.
If the dc.count does not match the db properties # of documents, you might have deletion stubs hanging around your database.
You can search this forum to find out how to purge deletion stubs if that is your issue.
Subject: RE: Database properties lists fewer documents than in database
That’s the problem. They’re not deletion stubs. In that case, I had a program check all the documents in the All Documents view and ALL of them had content. I even manually opened random documents throughout the All Documents view and all opened. And, even weirder, when I reopened the NSF and checked the Documents count before posting, I checked the Database Properties and it stated 81 (and this NSF is disconnected from it’s Domino server, so it couldn’t have gotten new mail).
We have to handle the NSFs as we receive them.
The attempt at purging deletion stubs listed here:
Didn’t work too well. Probably due to the fact it’s saying on the server, but I attempted the first method and reopened the NSF and the Document count on the database dropped to 1, but the All Documents view showed 4 and the Inbox still had 53.
The Inbox only shows that it has 53 unread items, but the actual view is empty. There’s also a folder that claims an unread item, but it too is empty.
The All Documents view shows 1 email and 3 To Do items, but the database lists only 1 Document in the Database Properties, and considering it originally listed 80, that didn’t work.
Ignore the unread marks. They can get corrupted a variety of ways (search this forum).
I would try doing a compact and fixup (locally or on the server). Since the database is small, you should be able to make a new copy. Check to see what the new copy says. It should not have any deletion stubs.
It might be informative to see what code you are using to count alldocuments.
Well, like I said, I’m not connected to a Domino server. This NSF was taken from one and is now on a machine that is not connected to any server.
And, again, I have to handle it as I receive it. The database, as received, shows more documents than the database claims.
Here is an example sub I use to count the documents:
Private Sub DisplayCount(ByVal NSFPath As String)
Dim lnSession As Domino.NotesSession
Dim lnDatabase As Domino.NotesDatabase
Set lnSession = New Domino.NotesSession
lnSession.Initialize
Set lnDatabase = lnSession.GetDatabase("", NSFPath)
If lnDatabase.IsOpen = False Then GoTo CouldNotOpen
MsgBox "Number of documents in NSF: " & lnDatabase.AllDocuments.Count
GoTo CleanUp
CouldNotOpen:
MsgBox "Could not open the NSF"
GoTo CleanUp
CleanUp:
Set lnDatabase = Nothing
Set lnSession = Nothing
End Sub
Doing a fixup had an interesting result. Doing a fixup with the option FIXUP_NODELETE to try and keep it from deleting “corrupt” documents made it change the document count to 0.
The compact seemed to correct the count, but that’s something I can’t do. The fixup doesn’t change the size, so it isn’t noticeable that I had to refresh something, but the compact changes the size noticeably, especially with this NSF, which is only using 29% of it’s space.
Subject: RE: Database properties lists fewer documents than in database
I understand Harley, but you should let the folks that sent you the original database know that their copy probably has corruption, and risk losing the whole database if it’s continued to be used without fixing it up.
Subject: RE: Database properties lists fewer documents than in database
They’re being informed.
The thing is, I don’t know if it was an issue of the database possibly being corrupted, as looking through documents in the database, the caption of the tab that denotes that document has (TRUNCATED) at the beginning, and the document properties lists the size like:
12,345 (bytes) + 678,901 (truncated)
Great thing to notice this far in, huh? I’m maybe thinking they were removing attachments from the documents (as some documents make reference to them or display icons that “house” 0 byte attachments) and that caused something odd to happen.
Of course, seeing as the names.nsf we received along with this email database has a similar document count issue (lists 0 documents when there are over 600) without any truncated documents, I don’t believe being truncated caused the issue.
In any case, as doing a SELECT @ALL gives me a document array containing all the documents in the databases, I guess my issue is solved.
Same NSF:Database Properties shows Document count of 80
All Documents shows 1580 items, all seem valid
Doing a search of @ALL on the database only returns 1290 documents
I need to get information from every document in the database as we receive it, but I can’t tell how to get all documents from this NSF.
Another NSF, the log.nsf for the user I have the email NSF of, lists 0 Documents in the Database Properties, but the @ALL search gives over 5000 documents.
Subject: RE: Database properties lists fewer documents than in database
Downloaded it and used it to look at a fresh copy of the NSF in question.
Database properties lists 80 documents
Notes Peek lists 1,579 documents and 127 deletion stubs
The All Documents view of the email database has 1,579 documents.
Trying to find some way to have the database correct it’s count without a compact (can’t do that). A fixup with the FIXUP_VERIFY option worked for this database, but on another that has the same issue it dropped the Document count in the Database Properties to 0, while a fixup without that option corrected it but caused the email database to have it’s Document count go to 0 (without removing any documents).
Subject: RE: Database properties lists fewer documents than in database
I don’t have access to any version of the database but the one I have, and it’s not and can’t be connected to it’s Domino server. I also can’t compact the copy I have as we have to handle it as is, and receiving a database that’s 1.6 GB but returning it with all the information they wanted as a 300 MB database wouldn’t go over well.
But I’ve retried doing a Search “SELECT @ALL” on the database from the NotesDatabase COM object and that seems to have worked fine. I guess when I got a wrong number I’d actually performed something that changed the document count in the copy of the database I was testing on.