Microsoft KB Archive/196197

= You receive an error message when you get a file from a project label by using OLE automation =

Article ID: 196197

Article Last Modified on 4/28/2004

-

APPLIES TO


 * Microsoft Visual SourceSafe 5.0 Standard Edition
 * Microsoft Visual SourceSafe 6.0 Standard Edition

-



This article was previously published under Q196197



SYMPTOMS
When you use Visual SourceSafe (VSS) OLE automation to get a version of a file based on a project-level label, the following unexpected run-time error might occur:

-2147166583

Version not found.



CAUSE
This problem occurs when you are using a Visual SourceSafe version 5.0 database.



RESOLUTION
Do one of the following to work around this problem:
 * Upgrade the database to the version 6.0 format, which also requires the Visual SourceSafe 6.0 client.
 * Add one extra line of code to your task procedure (see the MORE INFORMATION section of this article for details).



STATUS
This behavior is by design.



MORE INFORMATION
In the Visual SourceSafe Explorer, you can retrieve a particular version of a file based on a project label by viewing the history of that file, selecting the inherited project label, and clicking Get. Alternatively, you can specify the file and the label from the command line.

You can use the following sample Visual Basic code to accomplish the same task by using OLE automation, assuming that the database you are trying to access is in the Visual SourceSafe 6.0 format: Dim objVSSDB As VSSDatabase Dim objVSSFile As VSSItem Dim objSpecificVer As VSSItem

Set objVSSDB = New VSSDatabase

' Assign values to the Open method parameters. objVSSDB.Open srcsafeini, username, password

' Sets file.txt to the object variable. Set objVSSFile = objVSSDB.VSSItem("$/Project1/file.txt", False)

' Sets the version of file.txt associated with ProjectLabel. Set objSpecificVer = objVSSFile.Version("ProjectLabel") objSpecificVer.Get "c:\Project1\file.txt" When you access objects in a Visual SourceSafe 5.0 database, you need to add one more line of code. In the above sample, when the objSpecificVer object is set, the .VersionNumber property contains the correct version number of the File.txt based on the project label, assuming that a valid label is sent to the .Version property, but it still contains an invalid object. To work around this, add the following line of code just after you set objSpecificVer and just before you execute the Get method. For example: Set objSpecificVer = objSpecificVer.Version(objSpecificVer.VersionNumber) This line sets objSpecificVer explicitly by using its own .VersionNumber property, from which the .Version property successfully returns a valid object.

