Monday, March 26, 2012

How to save a Database project using DTE?

Hi All,

How can we save a Database project (not a SQL Server project) using Application Object Model? I was able to save a SQL Server project using the DTE like this:

Project project = null;
Solution solution = _applicationObject.Solution;
foreach (Project prj in solution.Projects)
{
if (prj.Name.Equals(projectName))
{
project = prj;
break;
}
}
if (project != null)
{
project.Save(project.FileName);
}

But for an Oracle Database project it gives an exception saying that Save() method is not implemented in DTE. A similar kind of problem occured for me when I tried to add an item to a Oracle Database project using DTE.
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=495993&SiteID=1

Can anybody give me a hint to find a solution for this?

Best regards,
Imesh

Sorry, generic database projects don't implement DTE.

However, there is a workaround using the base ide. in your macro code, you need to make the solution explorer that active tool window, and then navigate down to the project node and select it. Then run

DTE.ExecuteCommand ("File.SaveSelectedItems")

That should do it.

|||Thanks Kenneth! I will try that out..!

Best regards,
Imesh

No comments:

Post a Comment