将vb应用程序与数据库一起部署到其他计算机中 [英] Deploying vb application along with the database into other machine

查看:95
本文介绍了将vb应用程序与数据库一起部署到其他计算机中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我在vb.net中创建了一个带有数据库(mdf)文件的简单应用程序。我已经把它变成了一个安装程序。我把它安装在我的电脑上,程序运行成功,我可以添加,保存,删除.etc,因为它在我的应用程序中的功能。但问题是,当我将其安装到其他PC时,应用程序无法访问数据库。是否还需要将sql server安装到该PC(没有安装sql server)。请帮助。我是新手。

Hi. i have made a simple application in vb.net w/ a database(mdf)file. ived already made it an installer. i installed it on my pc and the program works successfully, i can add, save, delete.etc as it featured in my application. but the problem is when i installed it to other pc the application cant access to the database. does it also required to installed sql server to that pc(w/o sql server installed).Please help. im a newbie.

推荐答案

如果您在应用程序中使用过SQL服务器,那么您的其他PC将需要访问SQL服务器的实例才能工作 - 您可能需要找到它并指定连接字符串作为安装程序的一部分。您不能在代码中使用SqlConnection,SqlCommand和类似对象,而无需为每台预期运行该应用程序的PC访问SQL服务器的安装。 1



有这样的方法:如果您将数据库用作独立的数据存储(一次不会被多个应用程序或用户访问),那么您可以更改代码以使用Access / Jet,SQLCE或SQLite - 其中任何一个都不需要安装相应的程序集。通常,更改代码以使用它们并不是一项重要工作,它主要只是将SqlCommand更改为SqlCeCommand或SQLiteCommand对象等等。 (有一些例外情况,取决于您使用的SQL服务器设施,但基本情况通常会直接结束)





1 - 这并不意味着你需要在每台PC上安装每个应用程序的SQL服务器 - 事实上你绝对不应该!

[/ EDIT]
If you have used SQL server in your application, then your "other pc" will need access to an instance of SQL server in order to work - and you will probably need to locate it and specify the connection string as part of your installer. You cannot use SqlConnection, SqlCommand and such like objects in your code without an installation of SQL server being accessible to each and every PC that is expected to run the application.1

There are ways round this: If you are using the database as a standalone data store (which will not be accessed by more than one application or user at a time) then you can change your code to use Access/Jet, or SQLCE, or SQLite - none of which require more than the appropriate Assemblies to be installed. Generally, it's not a major job to change your code to use them, it is mostly just changing SqlCommand to SqlCeCommand or SQLiteCommand objects and so forth. (There are exceptions to this, depending on what SQL server facilities you have used, but the basics normally go straight over)


1 - This doesn't mean that you need to install SQL server with each application on each PC - in fact you definitely shouldn't!
[/EDIT]


这篇关于将vb应用程序与数据库一起部署到其他计算机中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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