简体   繁体   中英

Inability to create a database in C# Visual Studio

I have created a project in Visual Studio using a Windows Form application C#.

However when I try to add a service-based database to the project the following message appears:

The file \\\\(file name has not been included for privacy reasons)\\mydocuments\\visual studio2010\\Projects\\Experiment\\Experiment\\Experiment.mdf is on a network path that is not supported for database files. CREATED DATABASE failed. Some file name listed could not be created. Check related errors. User does not have permission to alter database. 'FF557489-6500-4C96-86DA-B07E7615056D', or the database does not exist. ALTER DATABASE statement failed. User does not have permission to alter database 'FF557489-6500-4C96-86DA-B07E7615056D', or the database does not exist. ALTER DATABASE statement failed. The database 'FF557489-6500-4C96-86DA-B07E7615056D' does not exist. Supply a valid database name. To see available databases, use sys.databases.

(I would have included a picture of the error but Stackoverflow insists I have 10 reputation points before I am allowed to included images in a post).

Has anyone encountered this before and know a way around it?

critical part of your error message "is on a network path that is not supported for database files"

try making sure its on the local disk.

Recommendations:

1) Verify you can connect to your MSSQL database instance

2) Simply issue "create database MYDATABASE". Let MSSQL decide where to put the files (you'll have a database file and a corresponding database log file).

IMHO...

As per MSDN, Permissions to Create or Deploy a Database -

  1. Import database objects and settings
  2. Import server objects and settings
  3. Create or update a database project.
  4. Deploy new database or deploy with Always Re-create Databaseoption set
  5. Deploy updates to an existing database
  6. Use an assembly with the EXTERNAL_ACCESS option in a database project
  7. Deploy assemblies to a new or existing database

Please refer - Permissions to Create or Deploy a Database on MSDN

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM