Last post Oct 30, 2011 11:12 AM by hercegtomas
Oct 30, 2011 09:39 AMemail@example.com|LINK
I have a console application and I am trying to add a new data source. I am getting the mssage:
I have created an SQL database - MyDatabase by restoring from a backup.
Could not open new database c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\MyDatabase.mdf
CREATE DATABASE is aborted
An attempt to attach an auto-named database c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\MyDatabase.mdf failed. A database with the same name exists, or specified file could not be opened, or it is located on UNC share.
File activbation failure, the physical file c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\MyDatabase_log.ldf may be incorrect.
The log cannot be rebuilt when the primary file is read only.
I can access the database with SQL Server Management Studio.
How do I rectify this problem?
Oct 30, 2011 11:12 AM|hercegtomas|LINK
The user account you use to run the application does not have permissions to the database directory.
Are you launching the SQL Management Studio using the same user account as the console app?