2

I'm trying to follow this example but I get an Exception related to the connection string telling me that the server was not found or was not accessible. The tutorial itself tells me on step 5 to "Change the connection string to point to your computer running SQL Server". I don't know if my SQL Server is running or not and if it is I don't know what would be the name of the server. I know I installed SQL Server when I installed VS 2010 (I did a full installation), so it should be somewhere. I haven't changed anything in the SQL Server configuration so everything should be on what is default.

2 Answers 2

9

If you installed SQL Server along with VS 2010, you have SQL Server 2008 Express edition on your machine, and it is installed by default as a "SQLExpress" instance, so your connection string would have to be something like:

server=(local)\SQLExpress;database=(whatever_you_want);integrated security=SSPI;

This would expect that database you specify to already exist on your server.

If you want to programmatically create a database, you would have to connect to the master database

server=(local)\SQLExpress;database=master;integrated security=SSPI;

and then run a SQL statement something like this from your app:

CREATE DATABASE (newDatabaseName)
Sign up to request clarification or add additional context in comments.

2 Comments

Instead of (local)\SqlExpress, you can have .\sqlexpress
@ZombieDev: yes, both formats are equivalent - I personally prefer (local) since it's clearer to me - when I see .\SQLExpress, I often overlook the leading dot . ....
0

You can check under services (start/run/services.msc) whether your SQL server is running or not; or in your start menu under "sql server configuration manager". pls check if named pipes and tcp-ip are enabled.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.