I have seen this question asked at least twice but no answer.
I do I get the path of a DatabaseProject inside my Addin?
I understand that Database projects are of 'kind' vsProjectKindUnmodeled,
but that does not tell me how to get the path to the dbp file.
There must be some sort of com interface define somewhere?
Hello Fred,
your best bet is to use VSIP interfaces. Take a look at IVsHierarchy and
IVsProject.
IVsProject.GetMkDocument(VSITEMID_ROOT, out pbstrMkDocument) will likely
return what
you need.
'Unmodeled' (as I understand it) means that there are no Extensibility interfaces
implemented by
that project, so you can't get from it anything using Extensibility.
Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
> I have seen this question asked at least twice but no answer.
>
[quoted text clipped - 5 lines]
>
> There must be some sort of com interface define somewhere?
Fred - 21 Sep 2005 09:28 GMT
Thanks fior the reply.
Does unmodelled mean there is no com object that can be used behind the scene?
I've never touch extensibility before.
All I'm doing is writting an add for VS2003.
Not sure what IVsHierarchy, is that a VS2005 feature?I'm using VS2003
Here's the code I ended up with to add a sql file to the database project of
the solution.
Ideally I would haver like to test if the a given folder existed, create it
if not and then and add the new file in that folder.
string fileName = System.Environment.GetEnvironmentVariable("TMP") + "\\" +
storedProcName + ".sql";
//Save the code to file
if(SaveCodeToFile(fileName,SQLComand)){
//Should hopefully give us the name of the solution
string slnName =
System.IO.Path.GetFileNameWithoutExtension(applicationObject.Solution.FullName);
string item = slnName + "\\" + dbProjectName; // + "\\Queries"; //location
where the new file is to be added
//Handle on Solution Explorer window
EnvDTE.Window slnExplorer =
applicationObject.Windows.Item(Constants.vsWindowKindSolutionExplorer);
slnExplorer.Activate();
//get the Database project so we can add a folder to it.
//EnvDTE.UIHierarchyItem dbProj =
((EnvDTE.UIHierarchy)applicationObject.Application.ActiveWindow.Object).GetItem(item);
//dbProj.Select(vsUISelectionType.vsUISelectionTypeSelect);
//Select the folder into which we want to add the new stored
procedure.
EnvDTE.UIHierarchyItem X = ((EnvDTE.UIHierarchy)
applicationObject.Application.ActiveWindow.Object).GetItem(item);
X.Select(vsUISelectionType.vsUISelectionTypeSelect);
EnvDTE.Window newStoredProc =
(EnvDTE.Window)applicationObject.ItemOperations.AddExistingItem(fileName);
X.Select(vsUISelectionType.vsUISelectionTypeSelect);
//Clear up;
if(System.IO.File.Exists(fileName)){
System.IO.File.Delete(fileName);
}
}

Signature
Fred
> Hello Fred,
>
[quoted text clipped - 23 lines]
> >
> > There must be some sort of com interface define somewhere?