简体   繁体   中英

Visual Studio 2012 move local .sdf file to server computer

here is the problem I am facing now. I have created an application that uses local database (this was created by Add -> New Item -> Local Database . Afterwards I have added tables under this .sdf database. Then I have connected to this database using Add -> New Item -> ADO.NET Entity Data Model .

Everything works like a charm, unless I was asked to move this database to a place, where multiple people could access this database and work with it.

Therefore, as I have no previous experience with databases, I have treated this .sdf file as any other file (let's say Excel workbook) and I thought that I could simply take already existing database, copy it on server computer (eg \\Server001\\Database\\Database1.sdf ) and simply change connection string under app.config.

However the problem is that this does not work. As I didn't know how to change connection string, I created new application, where I have tried to connect to this database located on a server computer; however I received the following error: SQL Server Compact does not support opening database files on a network share .

I already have fully functioning program, but I have no idea how to make it work with multiple users. I have tied to google for solution, but all I could find is how to create local database, not how to make it accessible by placing it in server computer.

Could you guys please help me? If you need more details, please let me know! PS This is WPF application, .NET 4.5, created using Visual Studio 2012 Professional.

Thank you!

The error message pretty much sums up the problem: SQL Server Compact does not support opening database files on a network share.

SQL Server Compact (aka "local database") is to be consumed by a local application; even if it was a web app serving many requests, the application itself is local.

If you want to have multiple remote connections (ie centralized DB, distributed app), you should look at using an instance of SQL Server (any SKU would probably work, even SQL Server Express). Those will use MDF files instead of SDF files, so you might want to refer to Convert .sdf database to .mdf database . You'll probably also need to set up a user identity for your connection string, so check out this link on CREATE USER and Difference between a User and a Login in SQL Server to understand how that can be configured.

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