如何使用数据库创建exe文件,包括客户端系统所需的软件 [英] How to create exe file with database including and softwares needed at client system

查看:179
本文介绍了如何使用数据库创建exe文件,包括客户端系统所需的软件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个桌面应用程序。该应用程序包含后端数据库。

我们假设我为公司(数据库名称)数据库中的员工创建了一个表。(在SQL Server 2005中)

我的应用程序有一个存储员工详细信息的界面。现在我想用我的数据库和应用程序创建单个可执行文件

。我想在客户端mechine中安装该应用程序没有互联网。

现在我想知道如何做到这一点以及客户系统需要什么软件。



我的来源任务如下:



Windows xp sp2(客户端系统)

我的可执行文件(.exe文件)--->(我正在使用SQL Server 2005和VS 2008专业人员)

1.如何创建这个包含公司数据库的exe文件

2.客户端系统所需的软件是什么为了成功运行这个应用程序



如果可能的话,给我一步一步的指导es。





删除代码块 - 仅使用< pre>代码片段的标签 - OriginalGriff [/ edit]

I am developing a desktop application.The application contains back end database.
Let us say for example i created a table for employee in company(database name) database.(In SQL server 2005)
My application has an interface to store employee details.now i wanted to create single executable file
with my database and application.I wanted to install that application in clients mechine which have no internet.
now i wanted to know how to do that and what are the software needed at clients system.

My sources for the task is below:

Windows xp sp2(clients system)
My executable file(.exe file)--->(I am using SQL server 2005 and VS 2008 professional)
1.how to create this exe file which includes company database
2.what are the softwares needed at clients system in order to run this application successfully

if possible give me step by step guidelines.


[edit]Code block removed - only use <pre> tags for code fragments - OriginalGriff[/edit]

推荐答案

如果您的客户端是独立的并且需要SQL2005数据库,那么您将需要安装您的软件和SQL2005 (在他的机器上尽快表达)。如果没有在某处安装SQL Server来访问数据库,则无法使用SQL2005。您不能将SQL2005服务器嵌入到您的应用程序中。



但是,如果您需要单个用户使用SQL数据库,那么请查看SqlCE:它是SQL ,但完全包含在您的应用程序中,不需要外部软件。但是,它只是单个用户:任何应用程序中只有一个实例可以一次访问它的数据库。
If your client is to be standalone and needs an SQL2005 database, then you will have to install your software and SQL2005 (Express as a minimum) on his machine. SQL2005 cannot be used without the SQL server installed somewhere to access the database. You cannot embedd SQL2005 server into your application.

However, if you need an SQL database to be used by a single user, then look at SqlCE instead: it is SQL, but is fully contained within your application, no external software is needed. It is, however, single user only: Only one instance of any application can access it's database at a time.


除了OriginalGriff



无法在EXE文件中附加数据库。即使您将应用程序中的数据库文件作为资源添加,它也将是只读的。

但有一件事可能会解决你的目的。

1.将数据库作为资源附加到您的应用程序中。

2.将资源从资源复制到本地驱动器首次运行应用程序

3.使用本地驱动器中的数据库。



但我不知道这是否会解决您的目的与否。
In addition to OriginalGriff

It’s not possible to attach a database inside your EXE file. Even if you add the database file in your application as a resource then it will be read only.
But one thing may solve your purpose.
1. Attach the database as resource in your application.
2. Copy it from the resource into local drive in first run of the application
3. Use the database from the local drive.

But I don’t know whether this will solve your purpose or not.


如果您想将Access Data Base放在C#应用程序中,那么您应该这样做。

首先创建任何Access数据像这里的基地PirFahimDataBase。现在在Visual Studio中进入菜单并执行此操作



1:点击数据

2:添加新数据库

3:单击下一步

4:单击新建连接

5:现在通过单击更改并选择Microsoft Access数据库文件来更改数据源

6:点击浏览选择你创建的数据库



现在进入你的项目。您将在项目中拥有一个访问数据库文件。毕竟转到.cs文件并提供数据库连接字符串的路径



System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb .OleDbConnection();

conn.ConnectionString = @Provider = Microsoft.ACE.OLEDB.12.0; +

@数据源= PirFahimDataBase.accdb;



在这里,让我们注意你的数据没有额外的路径来源,因为您的Access数据库文件现在在您的项目中。所以只需输入数据库文件的名称。
If you want to put Access Data Base inside your C# application, then you should do this.
First of all create any Access data base like here "PirFahimDataBase". Now in your Visual Studio go to the menu and do this

1: Click Data
2: Add New Data Base
3: Click Next
4: Click New Connection
5: Now change the Data Source by clicking Change and select Microsoft Access data base files
6: Click Browse for selecting your created data base

Now take inside in your project. You will have an access data base file in your project. After all that go to your .cs file and give a path to your data base connection string

System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;" +
@"Data source=PirFahimDataBase.accdb";

Here, lets give an attention you have no extra path for your "Data Source" , because your Access Data Base file is in your project now. So just put the name of your Data Base File.


这篇关于如何使用数据库创建exe文件,包括客户端系统所需的软件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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