Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 sql connection failed

Author  Topic 

izac
Starting Member

1 Post

Posted - 2008-05-06 : 19:39:56
hello

i am making asp.net website and i face problem in accessing my database which is located at app_data folder.
my connection string is

Sqlconnection conn = new SqlConnection("Server=.\\SQLEXPRESS; Integrated Security=SSPI; uid=sa; pwd=; AttachDbFilename=|DataDirectory|Database_shop.mdf; Database=shopdata");


error says ..


Directory lookup for the file "C:\Users\izac\Documents\Visual Studio 2005\WebSites\aspconnectiontest\App_Data\Database.mdf" failed with the operating system error 5(error not found). Could not attach file 'C:\Users\izac\Documents\Visual Studio 2005\WebSites\aspconnectiontest\App_Data\Database.mdf' as database 'shopdata'.


Plz help

sam13
Starting Member

6 Posts

Posted - 2008-05-06 : 21:57:52
quote:
Sqlconnection conn = new SqlConnection("Server=.\\SQLEXPRESS; Integrated Security=SSPI; uid=sa; pwd=; AttachDbFilename=|DataDirectory|Database_shop.mdf; Database=shopdata");


Repleace Server in the above connectionstring with Data Source. You should remove this line Database=shopdata. Also if the login sa is password protected then you should specify the password in your connection string or else use this "Integrated Security=True;User Instance=True"

Sqlconnection conn = new SqlConnection("Data Source=.\\SQLEXPRESS; Integrated Security=SSPI; uid=sa; pwd=; AttachDbFilename=|DataDirectory|Database_shop.mdf;
Go to Top of Page
   

- Advertisement -