Archive for September, 2008
Obtaining connection string from visual studio
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.
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.
1 comment September 1, 2008

