Crystal Reports连接提供程序 [英] Crystal Reports Connection Provider

查看:65
本文介绍了Crystal Reports连接提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个必须同时运行sql server和oracle数据库的应用程序.因此,当我创建水晶报表时,我必须选择连接的提供程序.如何管理它以使我的报告与两个数据库兼容.有什么办法可以从代码后面设置提供程序?我可以通过代码动态设置提供程序吗?有其他替代方法吗?
请提供解决方案....:doh::doh::doh:


有什么方法可以将连接对象ya连接字符串而不是用户名和密码传递给SetDatabaseLogon()函数吗?还是有任何其他方法可以在运行时更改连接?:confused :: confused :: confused:

Hi All,

I''ve an application which has to work both sql server and oracle databases. So when I create crystal reports, I''ve to select provider for the connection. How can I manage it to make my reports compatible with both databases. Is there any way to set provider from code behind? Can I set provider dynamically through code? Is there any alternate ways???
Please give solution.... :doh: :doh: :doh:


Is there any way to pass connection object ya connection string to SetDatabaseLogon() function instead of username and password? Or is there any alternate way to change the connection at runtime?:confused::confused::confused:

推荐答案

我这样做如下:
I did it as follows:
public ReportDocument GetReportDocument(string reportid){
    bool success = GetReportData(reportid) && GetDBData();
    ReportDocument document = null;
    if(success == true){
        //create a document
        document = new ReportDocument();
        //Load it.
        document.Load(report.Path);
        //set the logon credentials for the database.
        document.SetDatabaseLogon(databaseobject.UserName, databaseobject.Password, databaseobject.Server, databaseobject.Database);
    }                                               //end if
    else{
        document = null;
    }                                               //end else
    return document;
}                                                   //end method GetReportDocument



您唯一需要做的就是获取数据库信息,并确保两个数据库使用的数据结构相同.

希望对您有所帮助.



the only thing you need to do is have the information for the database and additionally make sure the structure of the used data is the same for both databases.

I hope this helps.


我建​​议尝试制作这种格式的XSD文件

I would suggest try to make a XSD file in this format

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="dsACCLIST" targetNamespace="http://tempuri.org/ACCList.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/ACCList.xsd" xmlns:mstns="http://tempuri.org/ACCList.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Document">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="ACCLIST">
<xs:complexType>
<xs:sequence>
<xs:element name="ACCCODE" type="xs:string" />
<xs:element name="APPDATE" type="xs:dateTime" />
<xs:element name="CODE" type="xs:string" minOccurs="0" />
<xs:element name="GRPNAME" type="xs:string" />
<xs:element name="GIVENNAME" type="xs:string" />
<xs:element name="SURNAME" type="xs:string" />
<xs:element name="AMOUNT" type="xs:decimal" />
<xs:element name="LGROUP" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="DocumentKey1">
<xs:selector xpath=".//mstns:ACCLIST" />
<xs:field xpath="mstns:ACCCODE" />
</xs:unique>
</xs:element>
</xs:schema>



然后在水晶报表中,将此XSD用作使用ADO.Net数据集的数据源.
然后在您的项目中获取数据集中的数据.

将数据集命名为与XSD文件中指定的名称完全相同的名称,例如



Then in crystal report use this XSD as data source using ADO.Net datasets.
Then in your projct fetch the data in a dataset.

Name your dataset exactly the same name specified in the XSD file like

ds.Tables(0).TableName = "ACCLIST"



现在,将报表对象的数据源设置为您像这样从先前从数据库中获取的数据集



Now set the datasource of the report objectto the dataset you fetched from database earlier like this

rptReport.SetDataSource(ds)



希望这会有所帮助



Hope this would help


这篇关于Crystal Reports连接提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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