简体   繁体   English

SQL Server:存储数据库以实现可移植性

[英]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. 我已经以非管理员用户身份在Windows 7的SQL Server Management Studio中创建了具有8个表的数据库。 In Visual Studio Express 2010 on the same user I am developing a WPF application that needs to access that database. 在同一用户的Visual Studio Express 2010中,我正在开发需要访问该数据库的WPF应用程序。 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. 但是,数据库文件似乎保存在C:\\Program Files\\Microsoft SQL Server\\MSSQL10_50.MSSQLSERVER\\MSSQL\\DATA并且我无法从Visual Studio的“添加连接”功能访问该文件。 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. 此外,在开发的各个阶段,我将需要创建一个.exe以发送给同事进行测试。 Therefore, from what I understand the database needs to be included as a resource in the Visual Studio project. 因此,据我了解,数据库需要作为资源包含在Visual Studio项目中。 I have googled all day but found nothing relating to what I thought would be a common scenario. 我整日用Google搜索,但没有发现与我认为会很普遍的情况相关的信息。 How can I add the database as a VS resource and access it from C#? 如何将数据库添加为VS资源并从C#中访问它?

Thanks. 谢谢。

As a result of the comments.... 作为评论的结果...

SQL Express will provide you with the functionality that you require. SQL Express将为您提供所需的功能。 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 此外,可以通过MSSQL Management Studio工具访问SQLExpress(请记住,此默认实例为.\\SQLExpress

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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