C#中的Crystal Report相对数据库位置 [英] Crystal Report Relative Database Location in C#

查看:73
本文介绍了C#中的Crystal Report相对数据库位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我已经在医院管理系统C#中创建了一个项目,

在这个显示来自MS Access数据库的患者信息的项目中,我使用了Crystal Report"CrystalReport.rpt",对于此报告,我已经通过创建连接字符串在设计视图中声明了数据库位置.

现在我的问题是,在设计视图中创建了此连接字符串后,无论何时更改位置,我都必须提供"Hospital_Management_System.mdb"文件的确切位置,例如"C:\ Firdaus \ Hospital Management System \ App_Data \ Hospital_Management_System.mdb"项目的我也必须更改连接字符串,这可以通过代码来完成,但是创建安装文件后,安装后将无法执行同样的操作.

我已将此文件添加到App_Data文件夹中,并将路径指定为
OleDbConnection con =新的OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = | DataDirectory | \\ Hospital_Management_System.mdb");对于整个项目,除了crystalreport.rpt的连接字符串外,因为这是不可能的!

即使按预期更改了位置,它也可以正常工作...


如何使用Crystal Report的连接字符串?


在此先感谢,
Firdaus Shaikh

Hello There,

I have created a project in C#, Hospital Management System,

In this project to display patient information from MS Access database I have used Crystal Report "CrystalReport.rpt", to this report I have declared database location in Design View by creating Connection String.

Now my problem is as this connection string is created in design view I have to give the exact location of my "Hospital_Management_System.mdb" file like "C:\Firdaus\Hospital Management System\App_Data\Hospital_Management_System.mdb", whenever I change location of my project I have to change connection string also, this is OK with code, but When I have created setup file I can''t do the same after installing it.

I have added this file in App_Data folder and given path as
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\Hospital_Management_System.mdb"); for entire project except in connection string of crystalreport.rpt as this is not possible!

It works properly even after changing location as expected...


What can I do with connection string for crystal report?


Thanks in Advance,
Firdaus Shaikh

推荐答案

您将通过搜索TableLogOnInfo和ConnectionInfo找到所需的信息.这些结构将有助于动态设置Crystal Report的数据库参数.
You will find the required information by searching for TableLogOnInfo(s) and ConnectionInfo. These structures will help with setting the database parameters dynamically for a Crystal Report.


这篇关于C#中的Crystal Report相对数据库位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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