begin process at 2012 05 27 05:54:11
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Chaînes de caratères

 > ASP.NET - COMMENT INTERROGER UN CATALOGUE D'INDEXING SERVICES

ASP.NET - COMMENT INTERROGER UN CATALOGUE D'INDEXING SERVICES


 Information sur la source

Note :
Aucune note
Catégorie :Chaînes de caratères Source .NET ( DotNet ) Niveau :Débutant Date de création :28/12/2003 Date de mise à jour :28/12/2003 19:41:55 Vu / téléchargé :10 028 / 249

Auteur : fabrice69

Ecrire un message privé
Site perso
Ce membre participe au partage de revenus publicitaires
Commentaire sur cette source (2)
Ajouter un commentaire et/ou une note


 Description

Cliquez pour voir la capture en taille normale
Après avoir poser la source concernant ce même outil mais en ASP (http://www.aspfr.com/code.aspx?ID=18844), il fallait bien poster la version (toujours simple) en ASP.NET.

Etant donné que de nombreux exemples existent pour le langage C#, mon exemple sera en VB.NET.

Source

  • ' Fichier TestIndex.aspx
  • <%@ Page Language="vb" AutoEventWireup="false"
  • Codebehind="TestIndex.aspx.vb" Inherits="DotNetSysInfo.TestIndex"%>
  • <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//FR">
  • <HTML>
  • <HEAD>
  • <title>Test d'utilisation d'indexing Service</title>
  • <meta name="GENERATOR" content="Microsoft Visual Studio&nbsp;.NET&nbsp;7.0">
  • <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
  • <meta name="vs_defaultClientScript" content="JavaScript">
  • <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie3-2nav3-0">
  • </HEAD>
  • <body >
  • <form id="Form1" method="post" runat="server">
  • <asp:DataGrid id="MonDataGrid" runat="server" Width="100%" BorderColor="#3366CC"
  • BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="4">
  • <SelectedItemStyle Font-Bold="True" ForeColor="#CCFF99"
  • BackColor="#009999"></SelectedItemStyle>
  • <ItemStyle ForeColor="#003399" BackColor="White"></ItemStyle>
  • <HeaderStyle Font-Bold="True" ForeColor="#CCCCFF" BackColor="#003399"></HeaderStyle>
  • <FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>
  • <PagerStyle HorizontalAlign="Left" ForeColor="#003399"
  • BackColor="#99CCCC" Mode="NumericPages"></PagerStyle>
  • </asp:DataGrid>
  • </form>
  • </body>
  • </HTML>
  • ' -------------------------------
  • ' Fichier TestIndex.aspx.vb
  • ' Exemple simple de recherche dans un catalogue Index Services EN vb.net
  • Imports System.Data
  • Imports System.Data.OleDb
  • Imports System.Collections
  • Imports System.Collections.Specialized
  • Public Class TestIndex
  • Inherits System.Web.UI.Page
  • Protected WithEvents MonDataGrid As System.Web.UI.WebControls.DataGrid
  • Private MonoleDbSelectCommand1 As New System.Data.OleDb.OleDbCommand()
  • Private MondbAdapter As New System.Data.OleDb.OleDbDataAdapter()
  • Private MadbConnection As New System.Data.OleDb.OleDbConnection()
  • Private LaRequette As String = ""
  • Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
  • Private MaDataTable As New DataTable()
  • #Region " Code généré par le Concepteur Web Form "
  • 'Cet appel est requis par le Concepteur Web Form.
  • <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  • End Sub
  • Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
  • 'CODEGEN : cet appel de méthode est requis par le Concepteur Web Form
  • 'Ne le modifiez pas en utilisant l'éditeur de code.
  • InitializeComponent()
  • End Sub
  • #End Region
  • Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  • Me.MondbAdapter.SelectCommand = Me.MonoleDbSelectCommand1
  • Me.MonoleDbSelectCommand1.Connection = Me.MadbConnection
  • ' Initialisation de la connexion avec notre catalogue
  • Me.MadbConnection.ConnectionString = "Provider=MSIDXS;Data Source=DotNetQueDuBonheur"
  • ' Création de la requette pour ADO.NET avec la recherche du mot Machine et DotNet
  • LaRequette = "SELECT Rank, VPath, DocTitle, Filename, Characterization, Write " & _
  • "FROM SCOPE('DEEP TRAVERSAL OF ""/DotNetSysInfo""') " & _
  • "WHERE NOT CONTAINS(VPath, '""_vti_"" OR "".config""') " & _
  • "AND CONTAINS(Contents, '""Machine"" OR ""DotNet""') " & _
  • "OR CONTAINS(DocTitle, '""Machine"" OR ""DotNet""') " & _
  • "ORDER BY Rank DESC"
  • ' Assigne la requette et charge le résultat
  • Me.MondbAdapter.SelectCommand.CommandText = LaRequette
  • Me.MondbAdapter.Fill(MaDataTable)
  • ' Envoie le résultat dans le Datagrid
  • Me.MonDataGrid.DataSource = MaDataTable
  • Me.MonDataGrid.DataBind()
  • End Sub
  • End Class
  • ' --------------------------
' Fichier TestIndex.aspx 

<%@ Page Language="vb" AutoEventWireup="false" 
 Codebehind="TestIndex.aspx.vb" Inherits="DotNetSysInfo.TestIndex"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//FR">
<HTML>
 <HEAD>
  <title>Test d'utilisation d'indexing Service</title>
  <meta name="GENERATOR" content="Microsoft Visual Studio&nbsp;.NET&nbsp;7.0">
  <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
  <meta name="vs_defaultClientScript" content="JavaScript">
  <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie3-2nav3-0">
 </HEAD>
 <body >
  <form id="Form1" method="post" runat="server">
   <asp:DataGrid id="MonDataGrid" runat="server" Width="100%" BorderColor="#3366CC" 
    BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="4">
    <SelectedItemStyle Font-Bold="True" ForeColor="#CCFF99" 
     BackColor="#009999"></SelectedItemStyle>
    <ItemStyle ForeColor="#003399" BackColor="White"></ItemStyle>
    <HeaderStyle Font-Bold="True" ForeColor="#CCCCFF" BackColor="#003399"></HeaderStyle>
    <FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>
    <PagerStyle HorizontalAlign="Left" ForeColor="#003399" 
     BackColor="#99CCCC" Mode="NumericPages"></PagerStyle>
   </asp:DataGrid>
  </form>
 </body>
</HTML>

' -------------------------------
' Fichier TestIndex.aspx.vb
' Exemple simple de recherche dans un catalogue Index Services EN vb.net

Imports System.Data
Imports System.Data.OleDb
Imports System.Collections
Imports System.Collections.Specialized

Public Class TestIndex
 Inherits System.Web.UI.Page
 Protected WithEvents MonDataGrid As System.Web.UI.WebControls.DataGrid

 Private MonoleDbSelectCommand1 As New System.Data.OleDb.OleDbCommand()
 Private MondbAdapter As New System.Data.OleDb.OleDbDataAdapter()
 Private MadbConnection As New System.Data.OleDb.OleDbConnection()
 Private LaRequette As String = ""
 Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
 Private MaDataTable As New DataTable()

#Region " Code généré par le Concepteur Web Form "

 'Cet appel est requis par le Concepteur Web Form.
 <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

 End Sub

 Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
  'CODEGEN : cet appel de méthode est requis par le Concepteur Web Form
  'Ne le modifiez pas en utilisant l'éditeur de code.
  InitializeComponent()
 End Sub

#End Region

 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

  Me.MondbAdapter.SelectCommand = Me.MonoleDbSelectCommand1
  Me.MonoleDbSelectCommand1.Connection = Me.MadbConnection

  ' Initialisation de la connexion avec notre catalogue
  Me.MadbConnection.ConnectionString = "Provider=MSIDXS;Data Source=DotNetQueDuBonheur"

  ' Création de la requette pour ADO.NET avec la recherche du mot Machine et DotNet
  LaRequette = "SELECT Rank, VPath, DocTitle, Filename, Characterization, Write " & _
   "FROM SCOPE('DEEP TRAVERSAL OF ""/DotNetSysInfo""') " & _
   "WHERE NOT CONTAINS(VPath, '""_vti_"" OR "".config""') " & _
   "AND CONTAINS(Contents, '""Machine"" OR ""DotNet""') " & _
   "OR CONTAINS(DocTitle, '""Machine"" OR ""DotNet""') " & _
   "ORDER BY Rank DESC"

  ' Assigne la requette et charge le résultat
  Me.MondbAdapter.SelectCommand.CommandText = LaRequette
  Me.MondbAdapter.Fill(MaDataTable)

  ' Envoie le résultat dans le Datagrid
  Me.MonDataGrid.DataSource = MaDataTable
  Me.MonDataGrid.DataBind()

 End Sub

End Class
' --------------------------


 Conclusion

Pour les exemple sous C#, voici quelques uns :
- CodeProject : http://www.codeproject.com/aspnet/search.asp
- DevHood : http://www.devhood.com/tutorials/tutorial_details. aspx?tutorial_id=157

Bon Coding.

Romelard Fabrice

 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Sources du même auteur

Source .NET (Dotnet) SHAREPOINT 2007 - OBTENIR LA LISTE DES WEBPARTS DANS UNE PAG...
Source .NET (Dotnet) SHAREPOINT 2007 - OBTERNIR LA LISTE DES FEATURES D'UN SITE
Source avec une capture Source .NET (Dotnet) SHAREPOINT 2007 - CHARGER LA LISTE DES COLLATIONS SHAREPOINT...
Source avec une capture Source .NET (Dotnet) SHAREPOINT 2007 - CHARGER LA LISTE DES LANGUES INSTALLÉES DA...
Source .NET (Dotnet) C# - FONCTION TRÈS SIMPLE POUR ENVOYER UN MAIL VIA SMTP

 Sources de la même categorie

FONCTION : REMPLACER LES CARRACTÈRES ACCENTUÉS PAR LEUR ÉQUI... par promeythey
CHERCHER ET REMPLACER UN MOT DANS UN FICHIER TEXTE par roro59650
CONVERSION CARACTÈRES UTF-8 VERS FRANÇAIS par EricDD
FONCTION UCFIRST EN ASP par DesignerCreator
Source .NET (Dotnet) FONCTIONS DE VÉRIFICATION DE LA SYNTAXE D'UNE CHAINE par vladam

Commentaires et avis

Commentaire de Quebec1 le 05/01/2004 02:34:31

Bonjour!
Petite question:
Est-ce que tu sais comment inclure les mots ignorés dans la requête du "select" quand tu veux que la recherche soit la phrase exacte?
Ex.: sous le soleil. Donc je veux seulement cette phrase et non ceux qui un mot entre sous et soleil

Commentaire de ocean64210 le 12/10/2004 11:56:56

bonjour

ton exemple me renvoie sur cette ligne
Me.MondbAdapter.Fill(MaDataTable)

peux tu me dire pourquoi ?

merci

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,279 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales