How to attach .mdf file to .SQLEXPRESS

后端 未结 5 1671
死守一世寂寞
死守一世寂寞 2021-01-05 16:41

Tried this in as connection string

connectionString=\"Server=.\\SQLEXPRESS;
    AttachDbFilename=E:\\Database\\dnn49.mdf;Database=dnn49; 
    Trusted_Connect         


        
相关标签:
5条回答
  • 2021-01-05 16:47

    If you are still unable to attach the database after granting the NETWORK SERVICE (or other Service Account) Modify Permission to the folder, also add your own User ID (the one attaching) to the Folder with Modify Permission (even if member of Administrators and Administrators has Full Control on the Folder). Apparently, this is a bug in Windows 7.

    You can remove your User ID from the folder after successfully attaching the database(s).

    0 讨论(0)
  • 2021-01-05 16:50

    One other suggestion is to turn off UAC (you can turn it off just temporary to verify if it is a permission problem).

    0 讨论(0)
  • 2021-01-05 16:58

    If you're attaching from SQL Server Management Studio, it also works to run SSMS as an administrator. This then can take advantage of the fact that the Administrators group has full control over the file. Another much more rare circumstance is that you'll get this Access Denied error because the database is already attached. This is probably more obvious unless you have multiple instances of SQL Server running and you already attached it to another instance possibly.

    0 讨论(0)
  • 2021-01-05 16:59

    i can't say whether you people got the solution for the problem or not, but i suggest a simple one here...

    copy the mdf and ldf file to your SQLServer installation directory, you may place it in backup folder of the directory. then try it

    i had used it many times...

    Good Luck

    0 讨论(0)
  • 2021-01-05 17:02

    You must check the SQL Server Service account has modify permissions over the physical file "dnn49.mdf" , and modify permissions also over the folder that contains the file.

    0 讨论(0)
提交回复
热议问题