views:

29

answers:

4

I am developing ASP.NET 2.0 application using SQL Express 2005. I have attached my database with the application.

The Connection string:

 <add name="WCMIRConnectionString"  providerName="System.Data.SqlClient"
  connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=&quot;\App_Data\WCMIR.mdf&quot;;Integrated Security=True;Trusted_Connection=no;User Instance=True" />

When trying to connect the following error appears :

Cannot open database "dp-name" requested by the login. The login failed. Login failed for user 'Machine\useID'.

How can this error be resolved?

+1  A: 

First I think the connection string should be with |App_Data| not \App_Data\
Second Make sure that this user has permission on this folder and on this DB

Amr ElGarhy
A: 

Just try "|" instead of backslash in ur code.

LGAP
........................................................................................
Light
+1  A: 

You shouldn't need the AttachDbFileName if your database is already attached, but you should include InitialCatalog to indicate which database you would like to connect to.

orvado