Lm th? no ? s? d?ng m?t ASP.NET ?ng d?ng ? truy v?n m?t danh m?c d?ch v? ch? m?c b?ng cch s? d?ng Visual C#.NET

D?ch tiu ? D?ch tiu ?
ID c?a bi: 820983 - Xem s?n ph?m m bi ny p d?ng vo.
?i v?i m?t Microsoft Visual Basic.NET Phin b?n c?a bi vi?t ny, xem 820105.
Bung t?t c? | Thu g?n t?t c?

? Trang ny


Bi vi?t t?ng b?c ny m t? cch ? t?o ra m?t Danh m?c d?ch v? nh ch? m?c. Bi vi?t ny c?ng m t? cch s? d?ng m?t ASP.NET Web ?ng d?ng ? truy v?n d?ch v? ch? m?c catalog.

T?o m?t th m?c bi ki?m tra

  1. T?o m?t th m?c m?i trn ? c c?a my tnh c?a b?n. Tn th m?c myCatalogFolder.
  2. B?t ?u m?t tr?nh so?n th?o vn b?n nh Notepad, v sau dn vn b?n sau y trong m?t tr?ng ti li?u:
    y l ti li?u th? nghi?m ? ki?m tra truy v?n my ch? ch? m?c v s?a tn t?p tin l IndexText.text.
  3. Lu cc t?p tin nhC:\myCatalogFolder\IndexText.txt.

T?o m?t danh m?c d?ch v? ch? m?c

  1. Nh?p vo B?t ?u, b?m Ch?y, lo?i compmgmt.msc, sau b?m Ok.
  2. M? r?ng D?ch v? v ?ng d?ng.
  3. Nh?p chu?t ph?i D?ch v? ch? m?c, i?m ?nM?i, sau b?m Danh m?c.
  4. Trong cc Tn h?p vn b?n, lo?iTestCatalog.
  5. Nh?p vo Tr?nh duy?t, xc ?nh v? tr th m?c ni b?n mu?n ?t cc c?a hng, v sau nh?p vo Ok hai l?n.
  6. D?i C?a hng m?i T?o, b?n nh?n ?c thng bo sau:
    Danh m?c s? v?n off-line cho ?n khi d?ch v? ch? m?c ?c kh?i ?ng l?i
    Nh?p vo Ok.
  7. Nh?p chu?t ph?i D?ch v? ch? m?c, v sau Nh?p vo D?ng ? ngn ch?n d?ch v? ch? m?c.
  8. Nh?p chu?t ph?i D?ch v? ch? m?c, v sau Nh?p vo B?t ?u kh?i ?ng l?i d?ch v? ch? m?c.

Xc ?nh ph?m vi c?a cc c?a hng

Sau khi b?n t?o m?t c?a hng m?i, thm cc th m?c m b?n mu?n bao g?m trong ph?m vi c?a cc c?a hng. Ph?m vi l t?p h?p cc th m?c l bao g?m trong cc c?a hng v b? lo?i tr? t? cc c?a hng. Ph?m vi ?nh ngh?a n?i dung bao g?m trong ch? m?c v b? lo?i tr? kh?i ch? m?c. Cho m?i c?p ?c bao g?m ho?c b? lo?i tr?, t?t c? cc c?p con c?a n c?ng ?c bao g?m ho?c lo?i tr?.
  1. B?m p TestCatalog (cc c?a hng m b?n t?o trong ph?n "T?o ra m?t th m?c bi ki?m tra").
  2. Nh?p chu?t ph?i Th m?c, i?m ?nM?i, sau b?m Th muc.
  3. Nh?p vo Tr?nh duy?t, ?nh v? v sau b?m cc th m?c m b?n mu?n thm)C:\myCatalogFolder\), sau b?m Ok.

    Chu y D?i Bao g?m trong ch? m?c?, b?mCo.

T?o m?t ASP.NET Web ?ng d?ng

  1. B?t ?u Microsoft Visual Studio.NET.
  2. S? d?ng Visual C#.NET ? t?o ra m?t m?i ASP.NET Web ?ng d?ng d? n. Tn d? n IndexQueryApp. Theo m?c ?nh, WebForm1.aspx ?c t?o ra.
  3. Theo quan i?m thi?t k?, nh?p chu?t ph?iWebForm1, sau b?m Xem HTML Source.
  4. Thay th? m? HTML hi?n c b?ng sau m?u M? s?:
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="IndexQueryApp.WebForm1" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
          <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
          <meta name="CODE_LANGUAGE" Content="C#">
          <meta name="vs_defaultClientScript" content="JavaScript">
          <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
       <body MS_POSITIONING="GridLayout">
          <form id="WebForm3" method="post" runat="server">
             <asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 90px; POSITION: absolute; TOP: 136px" runat="server"></asp:TextBox>
             <asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 328px; POSITION: absolute; TOP: 138px" runat="server"></asp:DataGrid>
             <asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 92px; POSITION: absolute; TOP: 199px" runat="server" Text="Button"></asp:Button>
  5. Trong gi?i php Explorer, b?m chu?t ph?i voWebForm1, sau b?m Xem m?. Thay th? m? hi?n v?i m?u m? sau y:
    using System;
    using System.Data;
    namespace IndexQueryApp
       public class WebForm1 : System.Web.UI.Page
          protected System.Web.UI.WebControls.TextBox TextBox1;
          protected System.Web.UI.WebControls.DataGrid DataGrid1;
          protected System.Web.UI.WebControls.Button Button1;
    		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: The ASP.NET Web Form Designer requires this call.
    		/// <summary>
    		/// Required method for Designer support - do not modify
    		/// the contents of this method by using the code editor.
    		/// </summary>
    		private void InitializeComponent()
                                 this.Button1.Click += new System.EventHandler(this.Button1_Click);
                                 this.Load += new System.EventHandler(this.Page_Load);
          private void Button1_Click(object sender, System.EventArgs e)
             // Catalog Name
             string strCatalog = "TestCatalog";
             string strQuery="";
             strQuery = "Select DocTitle,Filename,Size,PATH,URL from Scope()  where FREETEXT('" +TextBox1.Text+ "')";
              // TextBox1.Text is the word that you type in the text box to query by using Indexing Service.
             string connstring = "Provider=MSIDXS.1;Integrated Security .='';Data Source="+strCatalog;
             System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connstring);      
             System.Data.OleDb.OleDbDataAdapter cmd = new System.Data.OleDb.OleDbDataAdapter(strQuery, conn);
             System.Data.DataSet testDataSet = new System.Data.DataSet();
             cmd.Fill(testDataSet, "SearchResults");
             DataView source = new DataView(testDataSet.Tables[0]);
             DataGrid1.DataSource = source;
  6. Trn cc Xy d?ng tr?nh n, nh?p vo Xy d?ng Gi?i php.

Ch?y ?ng d?ng

  1. Trn cc G? l?i tr?nh n, nh?p voB?t ?u ? ch?y cc ?ng d?ng.
  2. G? t? truy v?n ti li?u trong vn b?n h?p. (B?n c th? nh?p b?t k? t? t? cc IndexText.txt t?p.)
  3. Nh?p vo Nt. Nh?n th?y r?ng d? li?u l?i xu?t hi?n v ch?a cc k?t qu? truy v?n t? cc IndexText.txtt?p tin.

G? r?i

Ch? ?i cho ch? s? ?c xy d?ng

D?ch v? ch? m?c t? ?ng x? l? TestCatalog v chu?n b? m?t danh sch t? cho ch? m?c. Khi b?n ch?y m?u m?, b?n c th? khng nh?n ?c k?t qu? nhanh nh mong ?i v? d?ch v? ch? m?c ?i h?i m?t s? th?i gian ? xy d?ng ch? m?c.

? xc minh c?a cc ch? m?c, kh?i ?ng my tnh qu?n l? MMC snap-in. Click anh chi muc D?ch v? trong ngn bn ph?i, v sau xc minh r?ng cc Word Danh sch gi tr? cho TestCatalog l l?n hn 0. Nu Word Danh sch gi tr? l 0, ch? ?i cho ch? m?c ? xy d?ng danh sch.

D? li?u ch? m?c c th? ? b? h?ng

N?u t?m ki?m khng tr? v? k?t qu? d? ki?n s? t?m ki?m khi b?n truy v?n ch? m?c, d? li?u ch? m?c c th? ? b? h?ng. ? g? r?i cc v?n ? ny, d?ng l?i v sau kh?i ?ng l?i d?ch v? ch? m?c l?p ch? m?c t?t c? ti li?u m?t l?n n?a. thc hin vic nay, hay lam theo nhng bc sau:
  1. Nh?p vo B?t ?u, i?m ?nThit t, sau b?m B?ng i?u khi?n.
  2. B?m p Cng c? qu?n tr?, v sau b?m p chu?t Qu?n l? my tnh.
  3. Trong cy giao di?n i?u khi?n, b?m p vo D?ch v? v Cc ?ng d?ng.
  4. Nh?p chu?t ph?i D?ch v? ch? m?c, v sau Nh?p vo D?ng.
  5. Nh?p chu?t ph?i D?ch v? ch? m?c m?t l?n n?a, v sau Nh?p vo B?t ?u.


? bi?t thm chi ti?t v? d?ch v? ch? m?c, truy c?p vo cc Microsoft Web site sau:
? bi?t thm chi ti?t, nh?p vo s? bi vi?t sau ? xem cc bi vi?t trong c s? ki?n th?c Microsoft:
311521Lm th? no ? ch? s? ASP.NET n?i dung b?ng cch s? d?ng Microsoft Index Server
? bi?t thm thng tin, h?y b?m vao s? bi vi?t sau ? xem bi vi?t trong C s? Ki?n th?c Microsoft:
308202Lm th? no ? t?o v ?t c?u h?nh m?t c?a hng cho ch? m?c

Thu?c tnh

ID c?a bi: 820983 - L?n xem xt sau cng: 28 Thang Tam 2011 - Xem xt l?i: 2.0
p d?ng
  • Microsoft ASP.NET 1.1
  • Microsoft ASP.NET 1.0
  • Microsoft Visual C# .NET 2003 Standard Edition
  • Microsoft Visual C# .NET 2002 Standard Edition
T? kha:
kbquery kbservice kbdatabinding kbdataadapter kbwebserver kbwebforms kbhowtomaster kbmt KB820983 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:820983

Cung cp Phan hi


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com