数据库在应用程序文件 [英] database in application folder

查看:84
本文介绍了数据库在应用程序文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我希望我的数据库位于应用程序文件夹中,以便它可以移植,即它可以在任何计算机上运行而无需将数据库恢复到所有计算机。是否可以使用SQL数据库,如果是这样,连接到它的代码是什么。



完成此声明:



sqlconnection con = new sqlconnection(

Hi All,

I want my database to be in application folder so that it becomes portable i.e it could run on any computer without restoring the database to all computer. is it possible with SQL database if so what would be the code to connect to it.

complete this statement :

sqlconnection con= new sqlconnection ("

推荐答案

如果您使用SQL Server,您将在服务器上设置数据库。

因此,所有拥有权限的用户都可以访问它。访问数据库(和机器)



建议不要移动数据库,因为您的数据库预计会增长并且变得越来越不便携。



如需连接字符串,请尝试 http://www.connectionstrings.com/ [ ^ ]。
If you use SQL Server, you will be setting up the DB on a server.
As a result, it will be accessible to all users who have privileges to access the DB (and machine)

Moving the DB around is not recommended as your db is expected to grow and become less and less portable.

For a connection string, try http://www.connectionstrings.com/[^].


如果你想要一个便携式应用程序,你必须使用便携式数据库。

有更多的解决方案可以做到这一点,例如:SqLite,Sql Server Compact Edition,Xml等。



记住:

如果你想使用RDBMS,你必须安装正确的da tabase引擎并确保将DB dll复制到输出文件夹中,否则如果选择xml数据库则不需要db引擎。
If you want a portable application, you must use a "portable" database.
There are more solutions to do it, for example: SqLite, Sql Server Compact Edition, Xml ,etc.

Remember:
If you want to use a RDBMS, you must install the correct database engine and make sure that the DB dll are copied in the output folder, otherwise if you choose a xml database you do not need a db engine.


问题是Windows。 Vista和Windows 7不允许您将数据文件放入 Program Files 文件夹中的任何子文件夹。它会强制您使用特殊用户数据文件夹。这是一个安全问题。但是,您可以创建一个可以在数据库服务器上运行的脚本,该脚本将在安装应用程序时创建所有表,存储过程,函数,触发器和视图。
The problem is Windows. Vista and Windows 7 do not allow you to put data files into any subfolder inside the Program Files folder. It forces you to use the "special" user data folders. This is a security issue. You can, however, create a script that you can run on the database server that will create all of the tables, stored procedures, functions, triggers, and views when your app is installed.


这篇关于数据库在应用程序文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆