Omid Jackson
Omid Jackson

Reputation: 33

Error 40 - Could not a open connection to sql server

In my windows application there is an error. Please can anyone tell me what is my mistake in connection string for local database? This is my code:

<add name="ACT_WIN.Properties.Settings.Database1ConnectionString"
    connectionString="Data Source=(LocalDB)\v11.0;
    AttachDbFilename=|DataDirectory|\Database1.mdf;
    Integrated Security=True"
    providerName="System.Data.SqlClient" />

And this is my error:

error message

Upvotes: 1

Views: 459

Answers (1)

Mehdi23
Mehdi23

Reputation: 26

I think your Wrong is in app.config -> ConnectionString -> Data Source=. or someting else,without set other Properties try this in ConnectionString...

Data Source=(localdb)\v11.0;AttachDbFilename=|DataDirectory|\DB.mdf;integrated security=true;database=DB" providerName="System.Data.SQLExpress"

Good Luck

Upvotes: 1

Related Questions