Précédent   Forum des professionnels en informatique > Logiciels > Solutions d'entreprise > Business Intelligence > Crystal Reports > Connectivité
Connectivité Forum sur les problèmes de connexion CR/SGBD
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 18/08/2003, 17h10   #1
Membre éclairé
 
Inscription : août 2002
Messages : 301
Détails du profil
Informations personnelles :
Âge : 30

Informations forums :
Inscription : août 2002
Messages : 301
Points : 321
Points : 321
Par défaut [CR 9] [ASPX][C#]connexion via code

est ce qu'on pourrait effectuer la connexion à une base de données via code et non en paramétrant le report. le problème avec crystal report est que lorsque on fait un report qui se connecte sur une base X, le report ne fonctionnera pas sur une base Y. est ce qu'il existe une solution à ce problème.
Merci
nannous est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/08/2003, 08h32   #2
Membre éprouvé
 
Avatar de sur_uix
 
Inscription : mai 2002
Messages : 377
Détails du profil
Informations personnelles :
Localisation : Suisse

Informations forums :
Inscription : mai 2002
Messages : 377
Points : 471
Points : 471
Oui on peut modifier la connexion via code

Voici un exemple en VB avec ADO et le moteur CRAXDRT de Crystal
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
How TO CHANGE the DATA source
This example demonstrates how TO CHANGE the DATA source FROM native Access TO an OLEDB (ADO) DATA source BY USING the ConnectionProperty Object, AS well AS how TO CHANGE the TABLE name BY USING the Location property of the DatabaseTable Object,. CrystalReport1 IS connected TO the xtreme.mdb DATABASE found IN the \Program Files\Crystal Decisions\Crystal Reports 9\Samples\En\DATABASES folder. The report IS USING the Customer TABLE. A copy of the Customer TABLE IS added TO the pubs DATABASE ON Microsoft SQL Server.
 
 
' Create a new instance of the report.
Dim Report As New CrystalReport1
 
Private Sub Form_Load()
' Declare a ConnectionProperties collection.
Dim CPProperties AS CRAXDRT.ConnectionProperties
' Declare a DatabaseTable object.
Dim DBTable As CRAXDRT.DatabaseTable
 
' Get the first TABLE IN the report.
SET DBTable = Report.DATABASE.TABLES(1)
 
' Get the collection of connection properties.
Set CPProperties = DBTable.ConnectionProperties
 
' CHANGE the DATABASE DLL used BY the report FROM
' native Access (crdb_dao.dll) to ADO/OLEDB (crdb_ado.dll).
DBTable.DllName = "crdb_ado.dll"
 
'  The connection property bags contain the name AND value
' pairs for the native Access DLL (crdb_dao.dll). So we need
' TO clear them, AND then ADD the name AND value pairs that
' are required to connect to the OLEDB data source.
 
' Clear ALL the ConnectioProperty objects FROM the collection.
CPProperties.DeleteAll
 
' Add the name value pair for the provider.
CPProperties.Add "Provider", "SQLOLEDB"
 
' ADD the name value pair FOR the DATA source (server).
CPProperties.ADD "Data Source", "ServerA"
 
' Add the name value pair for the database.
CPProperties.Add "Initial Catalog", "pubs"
 
' ADD the name value pair FOR the user name.
CPProperties.ADD "User ID", "UserName"
 
' Add the name value pair for the password.
CPProperties.Add "Password", "password"
 
' SET the TABLE name.
DBTable.Location = "Customer"
 
Screen.MousePointer = vbHourglass
' Set the report source of the viewer and view the report.
CRViewer91.ReportSource = Report
CRViewer91.ViewReport
Screen.MousePointer = vbDefault
End Sub
sur_uix est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/08/2003, 13h50   #3
Membre éclairé
 
Inscription : août 2002
Messages : 301
Détails du profil
Informations personnelles :
Âge : 30

Informations forums :
Inscription : août 2002
Messages : 301
Points : 321
Points : 321
Citation:
le moteur CRAXDRT de Crystal
qu'est ce que le moteur CRAXDRT de Crystal et quel est le package qu'on doit importer?
Merci
nannous est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/08/2003, 15h12   #4
Membre éprouvé
 
Avatar de sur_uix
 
Inscription : mai 2002
Messages : 377
Détails du profil
Informations personnelles :
Localisation : Suisse

Informations forums :
Inscription : mai 2002
Messages : 377
Points : 471
Points : 471
Pour pouvoir utiliser un rapport crytsal depuis un outil de développement .Net VB Delphi etc... il faut 1. la version Developpeur de Crystal puis utiliser un des moteurs de Crystal.
Pour C# il ne faut pas prendre le RDC (CRaxdrt) mais le RAS - COM Report Application Server SDK

Je n'y connais rien en C#, mais voici un petit exemple
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//********************************************
//
//File Name:     	SimpleLogonEngine.sln
//Created:       	May 30, 2002
//Author ID:     	CHO
//Purpose:       	This C# .NET sample web application
//                  demonstrates how to log on to a secure SQL database 
//                  using the database table objects of the ReportDocument 
//                  class to establish the connection.  This application 
//                  uses "Engine" in its title because it uses objects in 
//                  the CrystalDecisions.CrystalReports.Engine assembly to log 
//                  on to the database.
//
//********************************************
 
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
 
namespace SimpleLogonEngine
{
	/// <summary>
	/// Summary description for WebForm1.
	/// </summary>
	public class WebForm1 : System.Web.UI.Page
	{
		protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
 
		// CR variables
		CrystalReport1 crReportDocument;
		Database crDatabase;
		Tables crTables;
		TableLogOnInfo crTableLogOnInfo;
		ConnectionInfo crConnectionInfo;
 
 
		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
		}
 
		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
 
			//Create an instance of the strongly-typed report object
			crReportDocument = new CrystalReport1();
 
			//Create a new instance of the connectioninfo object and
			//set its properties
			//Note: This sample report connects to the sample SQL Server database, Pubs,
			//If you have access to SQL server, enter in your values for the ServerName,
			//UserID and Password properties to connect.  The report included with this
			//sample application connects using OLE DB and SQL authentication.
 
			crConnectionInfo = new ConnectionInfo();
			crConnectionInfo.ServerName = "Enter your server name";
			crConnectionInfo.DatabaseName = "Enter the database name";
			crConnectionInfo.UserID = "Enter the User ID";
			crConnectionInfo.Password = "Enter the password";
 
			//Get the tables collection from the report object
			crDatabase = crReportDocument.Database;
			crTables = crDatabase.Tables;
 
			//Apply the logon information to each table in the collection
			foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
			{		
				crTableLogOnInfo = crTable.LogOnInfo;
				crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
				crTable.ApplyLogOnInfo(crTableLogOnInfo);
			}
 
			//Once the connection to the database has been established for
			//each table in the report, the report object can be bound to the viewer
			//using the reportsource property of the viewer to display the report.
			CrystalReportViewer1.ReportSource = crReportDocument;
		}
 
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);
 
		}
		#endregion
	}
}
Le projet complet est ici
http://support.crystaldecisions.com/...engine.exe.asp

Bonne chance
sur_uix est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 07h04.


 
 
 
 
Partenaires

Hébergement Web