Pragmatically Open Database connection - c#

I am working on a project and have scoured the internet for answers on this topic but could not find a single answer, not even an open source solution.
Maybe you guys could help me out.
In visual studio you can open the database connection window by browsing View -> server explorer -> add connection. that is all well and known but what if I wanted to open that same form from code or a certain API. I cant seem to figure it out but there must be some sort of way to access this form pragmatically since its native to Visual Studio.
For all who are unsure what form I'm talking about, here's a snippet:
So my question to you is, how can I , through code, open this window? If there is nothing built into Visual Studio and C#, do you know of any open source software that accomplishes this or will I have to recreate it with a windows form application?

I think you would need to build the form yourself if you need any custom logic etc in which case you could use the ConnectionStringBuilder classes and pass the validated fields from your custom form to the relevant builder class to generate the connection string. Visit here for more information.
Microsoft also has library on nuget that you could use, although it's deprecated so use with caution. The nuget file, which you can download manually, also contains the source code so perhaps you could use this to jump start your own UI component. https://www.nuget.org/packages/DataConnectionDialog

Related

Application Links item in Open/SaveFileDialog in C#

When showing the open file dialog, I want to show up the "App,lication Links" category in the left side pane on Vista/7. Visual Studio does that too when opening project files.
How can I do this with a standard OpenFileDialog-Object in C#? I am using WPF by the way, but I don't think that matters in this case.
You need to use FileDialog.CustomPlaces. That MSDN link contains some sample code to get you going. Ultimately this is wrapping the native functionality exposed by IFileDialog::AddPlace.

Extending Visual Studio / Team Foundation Server 2010

I am attempting to use a VSPackage to create a Tool window for visual studio 2010. I have all of that created. For my project I am attempting to access TFS 2010. For example when working on a project some files might get checked out and I make changes on them that I don't necessarily want to check in later. Rather that going through tfs and selecting all of the files I don't want to check in(can be very time consuming) I would like to be able to filter files / add files to a "do not check in" type of list. So basically If a add a file / filter for files to not check in. I want some way of connecting to the event of when someone wants to check in, the plugin / tool window can automatically deselect all of the files in the filter/ file list that I have set up. I have a good idea of what I want to do. I just need a good place to start in order to communicate with tfs. So I know I would need to be able to access my collections and also be notified of when someone wants to check in files/ that way I can modify the check in status of the file that I do not want to check in. Hopefully I made sense with all of that. Any help would be MUCH appreciated!!
The class TeamFoundationServerExt (http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.teamfoundation.teamfoundationserverext.aspx) may provide what you're looking for.
It contains the current TFS context inside Visual Studio - eg. the team project to which you're connected in Team Explorer.
From there you can get the VersionControlServer object, which in turn exposes check-in related events. More details in http://blogs.msdn.com/b/buckh/archive/2012/01/25/how-to-get-the-tfs-objects-used-in-our-own-ui-integration.aspx.
The blog post mentioned above has a nice code sample.
One last thing: If the files you're trying to filter out can be defined via regular expressions, you can use the Forbidden Patterns check-in policy, part of the Team Foundation Server Power Tools.

WPF Binding and Using Custom Sample Data in Visual Designer

Quick 1 sentence summary: I wrote a demo app [download src here][1] that doesn't properly display sample data in the Visual Studio Designer and I need help.
After 6+ years developing in C# and WinForms, I've decided to use WPF in my current project. I've written a small demo application to teach myself and experiment with WPF (you can see a screenshot [here][1]). The app simply downloads and displays recent news stories from the Google News RSS feed.
My first attempt at this resulted in the class called "GoogleNewsWidget." After reading about the MVVM model, however, I tried again and built "GoogleNewsWidget2" that attempts to utilize a more MVVM-oriented architecture. I'm not sure which implementation is best as they both seem to be working fine on the whole (and though I'd appreciate comments on which is better, it is not my primary question).
My main problem is that neither play very well with the Visual Studio Designer. The GoogleNewsWidget2 loads and displays data fine when its xaml is opened directly but does not display correctly when embedded into another xaml file . The GoogleNewsWidget does not display data in the Designer in either case.
Any help would be appreciated. Again, the source is available for download [here][1].
Thanks,
Jon
[1]: http://abstract.cs.washington.edu/~jfroehli/reflect/ Demo App Source Code
PS My original post had multiple hyperlinks to screenshots but its posting was denied by StackOverflow for spam prevention reasons. Thus, I created the [1] url, which contains screenshots and a link to source code. If someone could also help me figure out how to use the "Markdown" language for linking, I'd be grateful. :)
Assuming that the VS2010 designer works the way Blend 3 does, you have to provide "dummy" data -- the designer won't pull data from external sources.
Create an object that implements the same interface as your datasource (view model) and fill it with static data. Make sure it has a public, no-arg constructor.
Define it as a resource in your control, giving it a key like "DesignData".
In the root element of your control, add the attribute d:DataContext={DynamicResource DesignData}"
This will be used as the DataContext only when in the designer.

build setup with database

I have written the code and finished the project. It is a window app in c#. I also have a database in sql server 2005 which I used it in the application. I need to create a setup for it so that any user can install it in his machine. build->publish and then following the wizard is the right way perhaps.. but what about the database?
The same database I made won't be in all computers, so I need that database also bind with my application.
Here is a link to some intro level tutorials, this should get you started. I would focus on creating some sample "Hello World" type applications before you dive into database programming. If you don't start small with this stuff, it can get frustrating.
http://msdn.microsoft.com/en-us/library/aa288436%28VS.71%29.aspx
it sounds like you are looking for basic information on setting up a project, to truly document this is going to take a lot more than a post.
The basic project setup, is done via Visual Studio and the "File" -> "New" -> "New Project" option. You can then select the type of project you need and that will then setup the project for you.
For the database conection, you will want to look into the items in the System.Data.SqlClient namespace.

Visual Studio 2008 and C#

I'm an IT Professional with a background with developing ASP/VBscript/SQL web applications. I want to take some training and get up to speed with Visual Studio 2008 and C# so that I can take over a project at work and make updates/bug fixes in house rather than calling in a third party.
The web application I'll be working on was developed in Visual Studio 2005 with a mix of C# code and some Ajax.
When I load the source code into Visual Studio 2008 I received a warning that the Source Control Plugin wasn't installed. It's looking for SourceSafe which I don't have. Is this necessary to use?
I'm starting a training course in February called Introduction to Visual Studio C# 2008. Well this be adequate to get me going in the right direction to be able to update, fix, and make minor changes to our web application? This is a big opportunity for me and I don't want to blow it.
Thanks!
SourceSafe is a Software Configuration Management tool from Microsoft, and is not required. I WOULD recommend using some form of SCM, but flavor is a matter of preference.
If the pop-ups are annoying to you and you would like to disable them, then removing the SourceSafe bindings from the project should stop them.
From http://weblogs.asp.net/bkcarroll/archive/2004/03/08/86059.aspx :
Solution:
1 - Go to the folder containing the solution files and delete the following:
mssccprj.scc
MyProject.vssscc
vssver.scc
2 - Open MyProject.sln in your favorite text editor and remove the following section:
GlobalSection(SourceCodeControl) = preSolution
...
EndGlobalSection
3 - Go to the folder containing the project files and delete the following:
MyProject.vbproj.vspscc
mssccprj.scc
vssver.scc
4 - Open MyProject.vbproj in your text editor and remove the following lines:
SccProjectName = "SAK"
SccLocalPath = "SAK"
SccAuxPath = "SAK"
SccProvider = "SAK"
Now you can open the solution/project with no source control errors.
As far as the class goes, if you're already familiar with ASP/VBScript, you can probably pick up a C# class and figure out the rest. If not, I would suggest going for an ASP focused class that utilizes a C# back-end.
I would expect that a course named "Introduction to Visual Studio C# 2008" would probably not cover Ajax technologies, so you might want to look for some additional resources on that topic. (It might not even cover ASP.NET in significant depth, so I'd advise checking the syllabus, and if the ASP.NET coverage is weak then prepare for some additional learning on that topic as well.)
Re the Source Safe plug-in: you will need this if you want to work on the code base (so you can check in and out of the existing VSS repository). You will not need it just to browse the code.
Well James that is up to you. I am not familer with the course but if you apply yourself and pay attention I'm sure you can achive your goal. Do not be afraid to move beyond just course work to learn new things. There is a lot of information about Visual Studio on the internet.
SourceSafe is not required to use Visual Studio.
Learning the basics of VS will definitely allow you to update and fix your web apps. VS allows you to work with all the technologies you mentioned all in one environment. Although ASP/VBScript are "legacy" at this point, there is still support for them in the VS environment.
James I'd suggest that you look at the free resources (video and textual) available to you on ASP.NET. I would presume that once you've read a few tutorials and watched some videos + taken your training course you should be able to maintain the code base. Add in the fact that sites like StackOverflow have a large .NET community and there are always people willing to help.
Good luck

Categories