Obtaining connection string from visual studio

September 1, 2008

I believe that some of you probably forget the syntax of the connection string used for connecting to a database from an application.

I had the following error message “A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server).” There are a lot of problems which could generate this error message. I tried enabling TCP/IP connection/ configuring firewall, etc. It was working. Finally, I tried changing the connection strings. It is still does not work, because the connection string was not correct.

Then I found out that I can obtain a connection string from the visual stdio. First, you need add a data connection to your database in visual studio first.

Add database connection in visual studio

Add database connection in visual studio

Then you select the server and the database.

Following figure is the result. A new dabase connection is added, and you can view its connection string from within visual studio. This technique really helps developers to quickly get a connection string which can be used in the application code.

Database connection and its property showing a connection string

Database connection and its property showing a connection string

Entry Filed under: Microsoft and .NET, database. Tags: , , , , , , .

1 Comment Add your own

  • 1. Tom  |  September 22, 2008 at 4:40 am

    Thanks! Saved me a few hairpulls.

    Reply

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Categories

Top Posts

Recent Posts

Pages

Archives

 

September 2008
M T W T F S S
« Aug   Oct »
1234567
891011121314
15161718192021
22232425262728
2930  

Blogroll

Books

Blog Stats

Top Clicks

Category Cloud

database Distributed application Education emergency response entrepreneurship firefighter (Feuerwehr) Flex/Flash German Language (Deutsch) Java Microsoft and .NET Risk Management (Disaster) Software Testing Uncategorized User Interface Design and Technology wcf Windows Workflow

Spam Blocked