如何使用数据库发布Windows窗体应用程序 [英] How to publish my windows form application with database

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

问题描述

我正在Viusal Studio 2012中使用vb.net和MS Access开发Winform应用程序.我完成了我的申请,现在我只想发布它.在我的项目解决方案中,我有表单和rpt文件(水晶报表).我将以下连接字符串用于我的数据库,该字符串不包含在我的项目解决方案中:

I am developing Winform application using vb.net and MS Access in Viusal Studio 2012. I completed my application and now i just wanted to publish it. In my project Solution I have forms and rpt files (crystal reports). I use the following connection string to my database which is not included to my project solution :

     conn.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Application.StartupPath & "\tblcmplist.mdb"

现在数据库应该在我的应用程序启动的文件夹中.如果我从bin文件夹运行,则可以运行,但是如果我通过右键单击solution-> publish来发布应用程序,并且如果我从发布位置运行,则会收到错误消息,例如缺少数据库文件.

Now the database should be there in folder where my application starts. If I run from the bin folder it works but if i publish my application by right clicking solution->publish and if i run from the published location i am getting error like the database file is missing.

我仍将数据库文件复制到应用程序的启动文件夹中,但仍然发生错误.请问有什么解决办法.

I copied my database file to that startup folder of my application still the error occurs. What is the solution plz help me.

我不得不问的另一件事是我在应用程序中使用了水晶报表.我安装了CRforVS_13_0_5开发人员版本,并在Visual Studio中创建了报告,并且可以查看工作正常的报告.但是,如果我在客户端计算机中运行该应用程序,则会出现错误,导致找不到水晶报表等等……我应该在我的客户端PC中安装什么以查看该报表?请帮助我,谢谢....

And one more thing I had to ask I am using crystal reports in my application. I installed CRforVS_13_0_5 developer version and I created reports in visual studio and I can view the report it works fine. But if I run the application in clients machin it gives the error could not find crystal report blah blah... what should i install in my client's pc to view the report ? Plz help me Thank you....

推荐答案

您将需要在应用程序设置中将数据库部署为"IncludeData".这将使其出现在ApplicationDeployment.DataDirectory定义的文件夹中(作为ClickOnce应用程序运行).要在VS中进行测试并进行部署,您将需要执行以下操作:

You will need to deploy your database as "IncludeData" in the application settings. That will make it appear in the folder defined by ApplicationDeployment.DataDirectory (running as a ClickOnce app). To test this from VS as well as deployed, you will want to do something like this:

string dataPath;
if (ApplicationDeployment.IsNetworkDeployed)
  dataPath = ApplicationDeployment.CurrentDeployment.DataDirectory;
else
  dataPath = System.Windows.Forms.Application.StartupPath;
dataPath = System.IO.Path.Combine(dataPath, "yourdatabasefilename");
If you deploy it in the Database folder and mark it as Include instead of Include(Data), the datapath would be 
Path.Combine(System.Windows.Forms.Application.StartupPath, "Database\yourdatabasefilename");

如果将其部署为数据,则在发布更新时,它将被向前复制.如果更改其本地副本,则将部署新版本,并将旧版本放置在Data文件夹的子文件夹中,该文件夹称为.\ pre.然后,如果您需要迁移数据,则可以.如果您希望获得更详细的数据库替换信息,请查看本文,该文章向您展示如何在两次ClickOnce更新之间保留数据: http://robindotnet.wordpress.com/2009/08/19/where-do-i-put-my-data-to-keep-it-safe-from-clickonce-updates/

If you deploy it as data, when you issue an update it will be copied forward. If you change the local copy of it, a new version will be deployed and the old version will be placed in a subfolder of the Data folder called .\pre. Then if you need to migrate data, you can. If you want more granularity over the replacement of your database, check out this article, which shows you how to retain data between ClickOnce updates: http://robindotnet.wordpress.com/2009/08/19/where-do-i-put-my-data-to-keep-it-safe-from-clickonce-updates/

查看全文

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