如何用exe附加数据库? [英] How to attach db with exe?

查看:219
本文介绍了如何用exe附加数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个用于在db中存储图像的图像存储应用程序.它的工作正常.
如何在exe上附加数据库以在任何计算机上使用?

我尝试过的事情:

I create a image store application for store image in db. its work on correctly.
How to attach db with exe for use on any computer??

What I have tried:

how to attach db with exe for any use on any computer?

推荐答案

您可以将MDF文件与应用程序可执行文件一起提供.您设置的项目应检查SQLExpress,如果不存在,则应安装它.然后,它还应该将MDF文件复制到所需位置.连接字符串应如下所示:
You can ship the MDF file along with application executable. Your set up project should check for SQLExpress and if not present should install it. Then, it should also copy the MDF file at desired location. The connection string should be like this:
Server=.\SQLExpress;AttachDbFilename=C:\MyFolder\MyDataFile.mdf;Database=dbname;
Trusted_Connection=Yes;


您正在使用哪个数据库?如果使用的是SQL CE db/或mdb,则可以直接使用可执行文件进行部署,或者,您可以选择创建安装程序,并将数据库和可执行文件一起部署在安装程序目录中.
如果使用的是mdf,则需要确保客户端已安装sql server,否则需要将sqlserver安装程序与应用程序安装程序一起包括在内.
What db are you using? If you are using SQL CE db / or mdb then you can deploy with your executable directly, alternatively you may choose to create installer and deploy the database along with the executable in the installer directory.
If you are using mdf then you need to be sure that the client has sql server installed else you need to include the sqlserver installer along with your application installer.


这篇关于如何用exe附加数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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