C# 连接到 sql server 数据库 mdf 文件而不在客户端机器上安装 sql server?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2054905/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Connecting to sql server database mdf file without installing sql server on client machine?
提问by Shantanu Gupta
I am creating a window application that need to use sql server database. I want to install this application to client machine without installing sql server so that my application can still connect to a database i.e mdf file that i will be providing at client system.
我正在创建一个需要使用 sql server 数据库的窗口应用程序。我想在不安装 sql server 的情况下将此应用程序安装到客户端计算机,以便我的应用程序仍然可以连接到数据库,即我将在客户端系统上提供的 mdf 文件。
How can i connect to a database(mdf) on client machine through my window application without installing sql server. ? I dont know is it possible or not.
如何在不安装 sql server 的情况下通过我的窗口应用程序连接到客户端计算机上的数据库(mdf)。? 我不知道这可能还是不可能。
If possible what will be the connection string in that case. Database need not be used in network.
如果可能的话,在这种情况下连接字符串是什么。数据库不需要在网络中使用。
Client mahine dont need any installation. Every thing needs to be run through pen drive
客户端机器不需要任何安装。每件事都需要通过笔式驱动器运行
采纳答案by Remus Rusanu
.mdf files are SQL Server database files. No other application can understand, read or update those files. If you need to open and mdf, you need a SQL instance. That instance can be local, can be an Express edition, or can be a remote one, doesn't matter. If your application needs a local SQL instance for it's own use then it can install SQL Server Express Edition when deployed.
.mdf 文件是 SQL Server 数据库文件。没有其他应用程序可以理解、读取或更新这些文件。如果需要打开和mdf,则需要一个SQL实例。该实例可以是本地的,可以是 Express 版本,也可以是远程版本,都没有关系。如果您的应用程序需要一个本地 SQL 实例供自己使用,那么它可以在部署时安装 SQL Server Express Edition。
回答by Chris Dunaway
You can try Sql Compact Edition or SqlLite. I think these are just a file based solution.
您可以尝试 Sql Compact Edition 或 SqlLite。我认为这些只是基于文件的解决方案。
回答by CoderTuhin
In that case you must have a server machine where your database files are stored. For that reason you have to use SQL Express Edition 2005 or 2008 in one machine and SQL server management studio to manage your database. Those are all free from Microsoft. The client machines will be connected through the connection string. Those machines don't need SQL instance or SQL server installed.
在这种情况下,您必须有一台服务器机器来存储您的数据库文件。因此,您必须在一台机器和 SQL 服务器管理工作室中使用 SQL Express Edition 2005 或 2008 来管理您的数据库。这些都是微软免费提供的。客户端计算机将通过连接字符串连接。这些机器不需要安装 SQL 实例或 SQL 服务器。
Regards..
问候..
回答by bahadorpn
You can search your MS-VS CD for SQLEXPRESS (please note the capital letters) and include it in your software when you create the set-up and your problem will be solved.
You don't have any other way except to use another database like access.
This database doesn't need its software.
您可以在 MS-VS CD 中搜索 SQLEXPRESS(请注意大写字母),并在创建设置时将其包含在您的软件中,您的问题将得到解决。
除了使用其他数据库(如 access)外,您别无他法。
这个数据库不需要它的软件。