Bonjour,
Je voudrais charger mon état paramétré à partir d'une requête Linq. Le paramètre est le matricule fourni depuis un textbox. Mon application est de type 3-tiers. L'agent est sélectionné par le matricule entré dans le textbox. J'utilise une classe de connexion pour Crystal Report que voici:
Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 namespace MonNameSpace { public class ConnectCrystalReport { static TableLogOnInfo crTableLogonInfo; static ConnectionInfo crConnectionInfo; static Tables crTables; static Database crDatabase; public static void ReportLogin(ReportDocument crDoc,string Serveur,string BaseDonnees,string ID_User, string MotDePasse) { crConnectionInfo = new ConnectionInfo(); crConnectionInfo.ServerName = Serveur; crConnectionInfo.DatabaseName = BaseDonnees; crConnectionInfo.UserID = ID_User; crConnectionInfo.Password = MotDePasse; crDatabase = crDoc.Database; crTables = crDatabase.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables) { crTableLogonInfo = crTable.LogOnInfo; crTableLogonInfo.ConnectionInfo = crConnectionInfo; crTable.ApplyLogOnInfo(crTableLogonInfo); } } } }
Lorsque je clique sur le bouton rechercher, j'ai ce message d'erreur;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 protected void Rechercher_Click(object sender, EventArgs e) { Agent MyAgent = new Agent(); ReportDocument RptAgent = new ReportDocument(); try { var req = AgentBLL.GetAgentByMatricule(txtMatriculeAgent.Text.Trim()); RptAgent.Load(Server.MapPath("~/Etats/EtatsAgents/EtatFicheAgent.rpt")); ConnectCrystalReport.ReportLogin(RptAgent, "Mon-PC\\MSSQLSERVER2008", "MaBDx", "User", "MotDePasse"); RptAgent.SetParameterValue("@AgentMatricule",txtMatriculeAgent); CrViewer.ReportSource = RptAgent; //RptAgent.Refresh(); } catch (Exception ex) { AfficherMessageErreur(ex); } }
Merci de m'aider
Partager