using data connection from server explorer in c#

4.4k views Asked by At

I use data connections to connect to a SQL Server 2008 Database. I search the web to know how to open, close and do queries (CRUD) but I found nothing.

enter image description here

In a first time, I would open a connection. I am stuck because I don't know how to get my connection "object" and use it in C# code.

Here is the begining of my code :

SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);

Thanks in advance !

2

There are 2 answers

1
Dave On BEST ANSWER

You can't use the database from the Server Manager. Instead include the database in your Solution Explorer. However you will still need the database to be in the Server Manager in order to use it in your Solution Explorer. You can add it to your Solution Explorer by right clicking on Solution Explorer and go to add -> new item.

0
TomTom On

You do not. This explorer is a developer tool to use in visual studio. It has no resemblance at all to what you do in your C# code.