Share via


Leçon 1 : Création du projet Visual Studio du schéma RDL

Nouveau : 17 juillet 2006

Dans ce didacticiel, vous allez créer une application console simple. Ce didacticiel suppose que vous utilisez Microsoft Visual Studio 2005 pour le développement.

Aa337503.note(fr-fr,SQL.90).gifRemarque :
Lorsque vous accédez au service Web Report Server qui s'exécute sur SQL Server Express with Advanced Services, vous devez ajouter « $SQLExpress » au chemin d'accès ReportServer. Par exemple : http://myserver/reportserver$sqlexpress/reportservice2005.asmx"

Pour créer une application console

  1. Dans le menu Fichier, pointez sur Nouveau, puis cliquez sur Projet pour ouvrir la boîte de dialogue Nouveau projet.

  2. Développez le dossier Projets Visual Basic ou Projets Visual C# .

  3. Cliquez sur l'icône Application console.

  4. Dans la zone Nom, tapez le nom de votre projet. Tapez le nom SampleRDLSchema.

  5. Dans la zone Emplacement, entrez le chemin d'accès de l'emplacement où vous voulez enregistrer le projet, ou cliquez sur Parcourir pour rechercher le dossier.

  6. Cliquez sur OK. Une vue réduite de votre projet apparaît dans l'Explorateur de solutions.

  7. Ensuite, vous devez ajouter une référence Web au point de terminaison ReportService2005. Dans le menu Projet, sélectionnez Ajouter une référence Web, et tapez le chemin d'URL de votre serveur de rapports ou accédez à celui-ci à l'aide des options de la fenêtre de navigation.

  8. Sélectionnez le point de terminaison ReportService2005, tapez ReportService2005 comme Nom de la référence Web, puis cliquez sur le bouton Ajouter une référence.

    Pour plus d'informations sur la manière de se connecter à un service Web Report Server, consultez Didacticiel : Accès au service Web Report Server avec Visual Basic ou Visual C#.

  9. Dans l'Explorateur de solutions, développez le nœud du projet. Un fichier de code portant le nom par défaut Program.cs (Module1.vb pour Visual Basic) a été ajouté à votre projet.

  10. Ouvrez le fichier Program.cs (Module1.vb en Visual Basic) et remplacez le code par le code suivant :

    Le code suivant fournit les stubs de méthode que nous utiliserons pour implémenter les fonctionnalités de chargement, de mise à jour et d'enregistrement.

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    using System.Xml;
    using System.Xml.Serialization;
    using SampleRDLSchema.ReportService2005;
    
    namespace SampleRDLSchema
    {
        class ReportUpdater
        {
            ReportingService2005    _reportService;
    
            static void Main(string[] args)
            {
                ReportUpdater reportUpdater = new ReportUpdater();
                reportUpdater.UpdateReport();
            }
    
            private void UpdateReport()
            {
                try
                {
                    // Set up the Report Service connection
                    _reportService = new ReportingService2005();
                    _reportService.Credentials =
                        System.Net.CredentialCache.DefaultCredentials;
                    _reportService.Url =
                       "http://myserver/reportserver/" +
                                       "reportservice2005.asmx";
    
                    // Call the methods to update a report definition
                    LoadReportDefinition();
                    UpdateReportDefinition();
                    PublishReportDefinition();
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine(ex.Message);
                }
            }
    
            private void LoadReportDefinition()
            {
                //Lesson 2: Load a report definition from the report 
                //          catalog
            }
    
            private void UpdateReportDefinition()
            {
                //Lesson 3: Update the report definition using the  
                //          classes generated from the RDL Schema
            }
    
            private void PublishReportDefinition()
            {
                //Lesson 4: Publish the updated report definition back 
                //          to the report catalog
            }
        }
    }
    
    Imports System
    Imports System.Collections.Generic
    Imports System.IO
    Imports System.Text
    Imports System.Xml
    Imports System.Xml.Serialization
    Imports SampleRDLSchema.ReportService2005
    
    Namespace SampleRDLSchema
    
        Module ReportUpdater
    
            Private m_reportService As ReportingService2005
    
            Public Sub Main(ByVal args As String())
    
                Try
                    'Set up the Report Service connection
                    m_reportService = New ReportingService2005
                    m_reportService.Credentials = _
                        System.Net.CredentialCache.DefaultCredentials
                    m_reportService.Url = _
                        "http://myserver/reportserver/" & _
                               "reportservice2005.asmx"
    
                    'Call the methods to update a report definition
                    LoadReportDefinition()
                    UpdateReportDefinition()
                    PublishReportDefinition()
                Catch ex As Exception
                    System.Console.WriteLine(ex.Message)
                End Try
    
            End Sub
    
            Private Sub LoadReportDefinition()
                'Lesson 2: Load a report definition from the report 
                '          catalog
            End Sub
    
            Private Sub UpdateReportDefinition()
                'Lesson 3: Update the report definition using the 
                '          classes generated from the RDL Schema
            End Sub
    
            Private Sub PublishReportDefinition()
                'Lesson 4: Publish the updated report definition back 
                '          to the report catalog
            End Sub
    
        End Module
    
    End Namespace 
    

Leçon suivante

Dans la prochaine leçon, vous allez utiliser l'outil de définition de schéma XML (Xsd.exe) pour générer des classes à partir du schéma RDL et les inclure dans votre projet. Voir Leçon 2 : Génération de classes à partir du schéma RDL à l'aide de l'outil xsd.

Voir aussi

Tâches

Didacticiel : Mise à jour des rapports utilisant les classes générées à partir du schéma RDL

Autres ressources

Report Definition Language

Aide et Informations

Assistance sur SQL Server 2005