Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Opening SQL file in VS 2010

5 views
Skip to first unread message

rbr

unread,
Dec 5, 2010, 3:38:28 PM12/5/10
to
I am creating a custom add-in for VS 2010 that manages database stored
procedures and other sql code. One of the features is going to be the
ability to edit the code files from VS. I am, however, having
difficulty understanding how to open the sql file in the IDE. I see
all the posts about the ItemOperations.OpenFile command which looks
like what I need but, I seem to be missing something in translation.
It looks like I need aDTE2 object but I am not sure how to get that?
I'm sure I am missing something too obvious. I would greatly
appreciate any help that could get me moving forward on this.

Best regards.

rbr

rbr

unread,
Dec 9, 2010, 5:21:32 PM12/9/10
to
I found the solution...

You need to get an instance of the DTE2 object for the running
instance of vs. The solution I found was this...

//get DTE2 object for running instance
DTE2 app =
(DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.
10.0");

// open the SQL file in the editor window
Application.ItemOperations.OpenFile("e:\sql\sqlfile1.sql",
Constants.vsViewKindAny);

Best,

rbr

0 new messages