How to Connect database SQL server 2008 with Visual Studio 2010 in C sharp application development



How to connect database SQL server 2008 with visual studio 2010

In computer software development , The database create and database design  is most important part .Any software must have database , It has to design and connect it with a interfacing IDE (Integrated Development Environment) . Desktop based software development and web based software development must have to connect database . Database connection is the major issue and a problem in computer software programming . In this session we have described about database connection with Visual Studio 2010 in C sharp language .If we can not connect database properly , it must be create problem in the time while we want to create an EXE file for installing the database software in our real application .

Here the database name is DUCT.mdf and it saved in drive D and the folder of the database name is db. A Gateway class is  used for handling the connection string . Here also a Gateway constructor  for initialize the class. It is format of object oriented programming and also used for tips and tricks for software development using computer.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace DuckDesign.Gateway


public class Gateway


string connectionString = @”server = .\D:\db\DUCT.mdf; integrated security = SSPI;”;

public string GetConnection()


return connectionString;