views:

150

answers:

1
<appSettings> 
  <add key="SqlConnectionString" 
       value="Data Source=.\SQLExpress;Persist Security Info=True;Integrated Security=SSPI;
       Initial Catalog=INFT3009_ASS1_C3104855.mdf;
       Trusted_Connection=Yes"/> 
</appSettings>

I am using the above connection string in my web.config. I attached the .mdf file to my database explorer of vs 2008 by selecting windows authentication and the test connection was successful.

when i run the code to execute the stored procedure, i am getting the following error

Cannot open database "INFT3009_ASS1_C3104855.mdf" requested by the login. The login failed. Login failed for user 'STTS\Karthikeyan'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot open database "INFT3009_ASS1_C3104855.mdf" requested by the login. The login failed. Login failed for user 'STTS\Karthikeyan'.

+1  A: 

Did you try to close the connection in VS 2008 before starting the application?

Arthur
close the connection ??i created sqlconnection and opened the conection.
Anuya
This did the trick....-> value="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\karthikeyan\Desktop\KOK\DB\INFT3009_ASS1_C3104855.mdf; Integrated Security=True;Connect Timeout=30;User Instance=True;Trusted_Connection=Yes"/>
Anuya
Close the connection in Visual Studio - right click on the connection in the server explorer - close connection. Sometimes I need that (when I want to restore a backup in example). But you'he already fixed your Problem :-)
Arthur