SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Cannot add database to Visual Studio


Cannot add database to Visual Studio

Author
Message
stephen.aa
stephen.aa
SSC-Enthusiastic
SSC-Enthusiastic (140 reputation)SSC-Enthusiastic (140 reputation)SSC-Enthusiastic (140 reputation)SSC-Enthusiastic (140 reputation)SSC-Enthusiastic (140 reputation)SSC-Enthusiastic (140 reputation)SSC-Enthusiastic (140 reputation)SSC-Enthusiastic (140 reputation)

Group: General Forum Members
Points: 140 Visits: 34
Hello:

I am using SQL Server Express 2017 with Visual Studio Professional 2017. I installed SQL Server in mixed mode.

I have a database that I created in SQL Server, with a few tables. It is located on a network drive so that it is properly backed up, rather than storing on my local hard drive. Perhaps this is a problem?

I am trying to add the database (ResourcePlanning.mdf) to Visual Studio. I am going to Server Explorer and Right-clicking Data Connections / Add Connection... Then selecting Microsoft SQL Server Database File / Continue and selecting the actual file via Browse. I have chosen both Windows Authentication and SQL Server Authentication options.

The error I am continually getting is: You don't have permission to open the file. Contact the owner or an administrator to obtain permission.

The problem is, I am the owner, and everything was created locally on my PC. SQL Server is installed on the same PC as Visual Studio. As I said, I placed the database file on a network path called \\w2012\Users\Steve A\MSSQL\DATA. This path has full permissions, as does the PC. I also have the correct local administration rights on my user account.

I have tried to move this file over to a local C-drive folder, and this too fails, saying I need permission to perform this action, that I require permission from the computers administrator to make changes to this file.

If I right-click the mdf file and select Properties / Security, I am told that I must have read permissions to view the properties of this object.

Strangely, I created the file under the same login as I am trying to connect and potentially relocate with.

Please let me know your thoughts on the matter.

Much Thanks!
Chris Harshman
Chris Harshman
SSC-Insane
SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)

Group: General Forum Members
Points: 22556 Visits: 5720
It sounds like there are multiple issues here.

First, where is the SQL Server service running that has this database, on your computer or on a server?

Second, when you say the database is "on a network drive so it is properly backed up", a file system level backup is not adequate protection for a database. Please make sure that BACKUP DATABASE command or a third party tool that performs database backups is used on a regular basis instead of file backups.
https://docs.microsoft.com/en-us/sql/t-sql/statements/backup-transact-sql

Third, you say everything "was created locally on my PC", but you say the database file is on a network share. Was the file created in SQL Server on your computer, detached, then moved to the network share, and then reattached to another SQL Server, or how did this file move?

Fourth, file permissions across a network share are based on the permissions granted through the share and on the server's local file system, not on who originally created the file and where it was created. Check with an admin to find the permissions for that network folder.

Fifth, when you say you are adding the database to Visual Studio, do you mean you are adding a reference to the database in a Visual Studio project? Some clarification may be needed here.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search