IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

SAP Crystal Reports Discussion :

C# Crystal Report Multiple DataSource


Sujet :

SAP Crystal Reports

  1. #1
    Membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Février 2018
    Messages
    150
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Février 2018
    Messages : 150
    Points : 63
    Points
    63
    Par défaut C# Crystal Report Multiple DataSource
    Bonjour, j'utilise Visual Studio et Crystal Report pour éditer un rapport. Ce dernier est constitué de 2 requêtes à partir d'une base de données Access. A l'execution du code de génération du rapport , j'obtient une erreur d'index.

    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
    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
     private void EditRptBtn_Click(object sender, RoutedEventArgs e)
            {
                EditRptBtn.Cursor = Cursors.Wait;
                EditRptBtn.Opacity = 0.5;
                DateTime pikerDate = Convert.ToDateTime(DecDatePiker.Text);
                string d = pikerDate.ToString("MM/dd/yyyy");
                string d1 = pikerDate.ToString("dd.MM.yyyy");
                string decVpfPath = ($"{ApplicationDirectories.dossierDoc}\\{ApplicationDirectories.appName}\\Dossiers {ApplicationDirectories.appName}\\Dec_VPF");
                string decVPFFile = ($"{decVpfPath}\\Dec_VPF_{d1}.pdf");
                string query = ($"SELECT Last(R_PORCS.ID) AS DernierDeID, R_PLANNING_APPRO.PL_DATE, R_LOTS.GROUP, R_LOTS.IDLOT, R_PORCS.FRAPPE," +
                    $" R_LOTS.NBPORC, R_PORCS.NUM_TUER, R_LOTS.DATE_DERREP, R_LOTS.H_DERREP, R_LOTS.DATE_CHARG, R_LOTS.H_CHARG, R_LOTS.DATE_DECHARG," +
                    $" R_LOTS.H_DECHARG, R_PORCS.H_PESEE, R_PORCS.ABC, R_PORCS.OBS1, R_PORCS.OBS2, R_PORCS.OBS3, R_PLANNING_APPRO.PL_SIGNEQ, R_PORCS.PORC," +
                    $" R_PORCS.MFS, R_PLANNING_APPRO.Quant, R_PORCS.P1CHconv FROM R_PLANNING_APPRO INNER JOIN(R_PORCS INNER JOIN R_LOTS ON R_PORCS.FRAPPE = R_LOTS.IDLOT)" +
                    $" ON R_PLANNING_APPRO.PL_FRAPPE = R_LOTS.FRAPPE GROUP BY R_PLANNING_APPRO.PL_DATE, R_LOTS.GROUP, R_LOTS.IDLOT, R_PORCS.FRAPPE," +
                    $" R_LOTS.NBPORC, R_PORCS.NUM_TUER, R_LOTS.DATE_DERREP, R_LOTS.H_DERREP, R_LOTS.DATE_CHARG, R_LOTS.H_CHARG, R_LOTS.DATE_DECHARG," +
                    $" R_LOTS.H_DECHARG, R_PORCS.H_PESEE, R_PORCS.ABC, R_PORCS.OBS1, R_PORCS.OBS2, R_PORCS.OBS3, R_PLANNING_APPRO.PL_SIGNEQ, R_PORCS.PORC," +
                    $" R_PORCS.MFS, R_PLANNING_APPRO.Quant, R_PORCS.P1CHconv HAVING(((R_PLANNING_APPRO.PL_DATE) =#{d}#) AND ((R_PORCS.ABC)<>'A')" +
                    $" AND ((R_PLANNING_APPRO.PL_SIGNEQ)='VPF')) OR (((R_PLANNING_APPRO.PL_DATE)=#{d}#) AND ((R_PORCS.OBS1)<>0) AND ((R_PLANNING_APPRO.PL_SIGNEQ)='VPF'))");
                comm = new OleDbCommand(query, conn)
                {
                    CommandType = CommandType.Text
                };
                conn.Open();
                OleDbDataAdapter dap = new OleDbDataAdapter(comm);
                DataTable dt = new DataTable("DEC_VPF");
                dap.Fill(dt);
                dt.WriteXmlSchema("DecVPF.xml");
                conn.Close();
                conn.Open();
                comm = new OleDbCommand("SELECT * FROM [R_Pds_Frappe_VPF]", conn)
                {
                    CommandType = CommandType.Text
                };
                OleDbDataAdapter dap1 = new OleDbDataAdapter(comm);
                DataTable dt1 = new DataTable("PdsFrappeVpf");
                dap1.Fill(dt1);
                dt1.WriteXmlSchema("Pds_FrappeVpf.xml");
                conn.Close();
                try
                {
                    DecVPF_CR cr = new DecVPF_CR();
                    cr.Database.Tables["0"].SetDataSource(dt);
                    cr.Database.Tables["1"].SetDataSource(dt1);
                    cr.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, decVPFFile);
                    var mess = MessageBox.Show("Souhaitez-vous imprimer le rapport ?", ApplicationDirectories.appName, MessageBoxButton.YesNo,
                        MessageBoxImage.Question);
                    switch (mess)
                    {
                        case MessageBoxResult.No:
                            EditRptBtn.Opacity = 1;
                            EditRptBtn.Cursor = Cursors.Arrow;
                            return;
                        case MessageBoxResult.Yes:
                            cr.PrintToPrinter(1, true, 0, 0);
                            EditRptBtn.Opacity = 1;
                            EditRptBtn.Cursor = Cursors.Arrow;
                            break;
                    }
                }
                catch (Exception ex)
                {
     
                    Messages.ErrorMessages(ex.Message);
                }
                EditRptBtn.Opacity = 1;
                EditRptBtn.Cursor = Cursors.Arrow;
            }

  2. #2
    Membre régulier
    Femme Profil pro
    ingénieur amélioration continue
    Inscrit en
    Février 2019
    Messages
    57
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 29
    Localisation : Tunisie

    Informations professionnelles :
    Activité : ingénieur amélioration continue
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2019
    Messages : 57
    Points : 76
    Points
    76
    Par défaut
    Bonjour,
    j'ai le meme souci que le tien sauf que j'utilise le VB.NET et j'aimerais connaitre comment tu a arrivé à résoudre ton problème . Est ce que tu a changé ton code ou bien tu a mrqué la discussion comme résolue sans mettre la solution
    merci d'avance
    " birds don't just fly they fall down and get up "

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Crystal Report] Problème avec la mise en forme à colonnes multiples
    Par SamRay1024 dans le forum SAP Crystal Reports
    Réponses: 3
    Dernier message: 14/10/2010, 15h19
  2. [WD9] Datasource Crystal Report
    Par medhan dans le forum WinDev
    Réponses: 0
    Dernier message: 19/03/2010, 00h40
  3. utiliser XML en datasource de Crystal report
    Par hyipicai dans le forum Windows Forms
    Réponses: 0
    Dernier message: 17/06/2009, 16h25
  4. Datasource d'un Crystal Reports
    Par Marc_27 dans le forum Windows Forms
    Réponses: 2
    Dernier message: 24/04/2009, 14h24
  5. Datasource Crystal report
    Par j0hn01 dans le forum ASP.NET
    Réponses: 0
    Dernier message: 09/03/2009, 13h13

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo