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
 General SQL Server Forums
 New to SQL Server Programming
 attach database

Author  Topic 

elic05
Yak Posting Veteran

62 Posts

Posted - 2010-05-16 : 18:12:21
I have created a db using visual studio 2010
it works fine when i run my application.

i want to manage it using SSMS.
when i connect to ssms, i dont see it on the list of the databases, so i right click databases and click attach...
i choose the myDb.mdf file.

i am loged to windows vista as admin.

i get an error:

quote:

Attach database failed for Server 'ELIC-PC\SQLEXPRESS'. (Microsoft.SqlServer.Smo)

Program Location:

at Microsoft.SqlServer.Management.Smo.Server.AttachDatabase(String name, StringCollection files)
at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabaseData.PrimaryFile.Attach()
at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabase.SendDataToServer()

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

Unable to open the physical file "C:\aspnetdb.mdf". Operating system error 5: "5(??access denied.)". (.Net SqlClient Data Provider)

Server Name: ELIC-PC\SQLEXPRESS
Error Number: 5120
Severity: 16
State: 101
Line Number: 1

------------------------------
Program Location:

at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)






please help
( i read a lot but is seems nothing gets me close to any solution.)

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-05-16 : 18:38:51
The SQL Server service account (the account under which the SQL service is running) does not have permission to the file or folder. Not surprising, seeing as it's the root of C:, which is restricted under newer operating systems (including Vista).

I suggest you move the DB files to an appropriate folder and make sure that the SQL Service account has full control of that folder.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

elic05
Yak Posting Veteran

62 Posts

Posted - 2010-05-16 : 19:36:46
The original place was d:/mySite/APP_DATA/
i moved it to c in order to solve the problem.
but...


Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-05-17 : 03:29:24
Move it back, check the permissions.

Oh, and run management studio as administrator. I don't mean logged in with an administrative account, I mean right click-> run as administrator.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

elic05
Yak Posting Veteran

62 Posts

Posted - 2010-05-17 : 04:31:51
I found the problem

in vs2010 i configured the db to use form authentication.
and i logged to ssms with windows authentication.

i got back to vs2010 configured it to run with windows authentication, and now i can attach it.

Go to Top of Page
   

- Advertisement -