如何设置相对晶体报告数据源位置(Access Database) [英] How to set relative the crystal report data source location (Access Database)

查看:88
本文介绍了如何设置相对晶体报告数据源位置(Access Database)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从应用程序处理c#.net窗口,因为我想添加水晶报告。

i知道如何添加水晶报告和数据源连接。



但问题是我想添加数据源连接相对路径(比如Data Source = | DataDirectory | Db.mdb或其他)所以任何计算机都可以运行我的应用程序而不需要太多更多设置。

I work on the c#.net window from application, in that i want to add crystal report.
i know how to add crystal report and data source connection.

But problem is i want to add data source connection relative path (like Data Source=|DataDirectory|Db.mdb or something else) so any computer can run my application without much more settings.

推荐答案

您好Archit,

我建议您提供连接字符串,查询和报告参数在运行时为您的报告。



-

谢谢



您好Archit,

您可以使用
Hi Archit,
I suggest you to provide connection string , query and report parameters at runtime for your report.

--
Thanks

Hello Archit,
You can use
CrystalDecisions.Shared.ConnectionInfo 

类通过您的代码指定连接字符串。您可以将这些连接参数存储在单独的文件(应用程序设置文件)中,并从那里读取代码。如果要更改连接,只需编辑此文件,以便任何计算机都可以运行您的应用程序。请参阅此课程的文档并使用它。

请参阅此方法以供参考



class to specify connection string at through your code. You can store these connection parameters in a separate file (App. settings file) and read them in your code from there. simply edit this file when you want to change connection so any computer can run your application. See documentation for this class and use it.
See this method for reference

private void SetConnectionInfo (string table, string server, string database, string user, string password)
        { 
           TableLogOnInfo logOnInfo = new TableLogOnInfo();
           logOnInfo = Report.Database.Tables[table].LogOnInfo;
           ConnectionInfo connectionInfo = new ConnectionInfo ();
           connectionInfo = logOnInfo.ConnectionInfo;

           connectionInfo.DatabaseName = database;
           connectionInfo.ServerName = server;
           connectionInfo.Password = password;
           connectionInfo.UserID = user;
           Report.Database.Tables [table].ApplyLogOnInfo(logOnInfo);
        }







希望这可能对您有所帮助。

-

谢谢




Hope this might be helpful to you.
--
Thanks


这篇关于如何设置相对晶体报告数据源位置(Access Database)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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