简体   繁体   中英

SQL Server: Store a database for portability

I have created a database with 8 tables in SQL Server Management Studio on Windows 7 as a non-admin user. In Visual Studio Express 2010 on the same user I am developing a WPF application that needs to access that database. However, the database file seems to be saved in C:\\Program Files\\Microsoft SQL Server\\MSSQL10_50.MSSQLSERVER\\MSSQL\\DATA and I cannot access that file from Visual Studio's Add Connection feature. Although I do have the admin password, files from that directory cannot be added. When I try to add it (after supplying the admin password) I get this message:

You don't have permission to open this file.
Contact the file owner or an administrator to obtain permission. 

Furthermore, during various stages of development I will need to create an .exe to send to a colleague for testing. Therefore, from what I understand the database needs to be included as a resource in the Visual Studio project. I have googled all day but found nothing relating to what I thought would be a common scenario. How can I add the database as a VS resource and access it from C#?

Thanks.

As a result of the comments....

SQL Express will provide you with the functionality that you require. Whilst it requires the machine to have the engine installed it does allow instance mode where you can directly attach database files in the connection string.

Additionally SQLExpress can be accessed via the MSSQL Management Studio tool (remember the default instance for this is .\\SQLExpress

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