Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Indexing search....

Indexing search....

Scheduled Pinned Locked Moved ASP.NET
databasehelplearning
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Moghan
    wrote on last edited by
    #1

    We are implemenmting the MicroSoft Indexing search in our site.our client asked to give provision to search the main folders only, not for SubFolders. So we decided to use the SHALLOW TRAVERSAL OF. But still now we didnt get the correct syntax. My code: System.Data.OleDb.OleDbConnection odbSearch = new System.Data.OleDb.OleDbConnection("Provider=\"MSIDXS\";Data Source=\"Agaram\";"); System.Data.OleDb.OleDbCommand cmdSearch = new System.Data.OleDb.OleDbCommand(); cmdSearch.Connection = odbSearch; odbSearch.Open(); cmdSearch.CommandText = "select Vpath, path, FileName, size, write, attrib, Characterization, DocTitle, rank from scope('' SHALLOW TRAVERSAL OF ("/Software")'') where FREETEXT(contents,'" + searchText + "') order by rank desc "; System.Data.OleDb.OleDbDataAdapter SqlDa = new System.Data.OleDb.OleDbDataAdapter(cmdSearch); DataSet Ds = new DataSet(); SqlDa.Fill(Ds); odbSearch.Close(); /Software is the main folder in my project The Error is at the Select Query. Error Details: Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1002: ; expected Source Error: Line 34: cmdSearch.CommandText = "select Vpath, path, FileName, size, write, attrib, Characterization, DocTitle, rank from scope('' SHALLOW TRAVERSAL OF ("/Software")'') where FREETEXT(contents,'" + searchText + "') order by rank desc ";

    E H 2 Replies Last reply
    0
    • M Moghan

      We are implemenmting the MicroSoft Indexing search in our site.our client asked to give provision to search the main folders only, not for SubFolders. So we decided to use the SHALLOW TRAVERSAL OF. But still now we didnt get the correct syntax. My code: System.Data.OleDb.OleDbConnection odbSearch = new System.Data.OleDb.OleDbConnection("Provider=\"MSIDXS\";Data Source=\"Agaram\";"); System.Data.OleDb.OleDbCommand cmdSearch = new System.Data.OleDb.OleDbCommand(); cmdSearch.Connection = odbSearch; odbSearch.Open(); cmdSearch.CommandText = "select Vpath, path, FileName, size, write, attrib, Characterization, DocTitle, rank from scope('' SHALLOW TRAVERSAL OF ("/Software")'') where FREETEXT(contents,'" + searchText + "') order by rank desc "; System.Data.OleDb.OleDbDataAdapter SqlDa = new System.Data.OleDb.OleDbDataAdapter(cmdSearch); DataSet Ds = new DataSet(); SqlDa.Fill(Ds); odbSearch.Close(); /Software is the main folder in my project The Error is at the Select Query. Error Details: Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1002: ; expected Source Error: Line 34: cmdSearch.CommandText = "select Vpath, path, FileName, size, write, attrib, Characterization, DocTitle, rank from scope('' SHALLOW TRAVERSAL OF ("/Software")'') where FREETEXT(contents,'" + searchText + "') order by rank desc ";

      E Offline
      E Offline
      eyeseetee
      wrote on last edited by
      #2

      If

      Moghan wrote:

      ("/Software")'') where FREETEXT(contents,'" + searchText + "') order by rank desc ";

      is a new line of code then you need to put a + in the line before at the end so that it knows its the end of that line of code

      M 1 Reply Last reply
      0
      • M Moghan

        We are implemenmting the MicroSoft Indexing search in our site.our client asked to give provision to search the main folders only, not for SubFolders. So we decided to use the SHALLOW TRAVERSAL OF. But still now we didnt get the correct syntax. My code: System.Data.OleDb.OleDbConnection odbSearch = new System.Data.OleDb.OleDbConnection("Provider=\"MSIDXS\";Data Source=\"Agaram\";"); System.Data.OleDb.OleDbCommand cmdSearch = new System.Data.OleDb.OleDbCommand(); cmdSearch.Connection = odbSearch; odbSearch.Open(); cmdSearch.CommandText = "select Vpath, path, FileName, size, write, attrib, Characterization, DocTitle, rank from scope('' SHALLOW TRAVERSAL OF ("/Software")'') where FREETEXT(contents,'" + searchText + "') order by rank desc "; System.Data.OleDb.OleDbDataAdapter SqlDa = new System.Data.OleDb.OleDbDataAdapter(cmdSearch); DataSet Ds = new DataSet(); SqlDa.Fill(Ds); odbSearch.Close(); /Software is the main folder in my project The Error is at the Select Query. Error Details: Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1002: ; expected Source Error: Line 34: cmdSearch.CommandText = "select Vpath, path, FileName, size, write, attrib, Characterization, DocTitle, rank from scope('' SHALLOW TRAVERSAL OF ("/Software")'') where FREETEXT(contents,'" + searchText + "') order by rank desc ";

        H Offline
        H Offline
        Harini N K
        wrote on last edited by
        #3

        Hi You need to split the string "\Software" as "\"" for each double quotes with escape character: See below: cmdSearch.CommandText = "SELECT Vpath, path, FileName, size, write, attrib, Characterization, DocTitle, rank FROM SCOPE('shallow traversal of " + "\"" + "/Software" + "\"" + "') where FREETEXT(contents,'" + searchText + "') order by rank desc "; Let me know if that works.

        Harini

        M H 2 Replies Last reply
        0
        • H Harini N K

          Hi You need to split the string "\Software" as "\"" for each double quotes with escape character: See below: cmdSearch.CommandText = "SELECT Vpath, path, FileName, size, write, attrib, Characterization, DocTitle, rank FROM SCOPE('shallow traversal of " + "\"" + "/Software" + "\"" + "') where FREETEXT(contents,'" + searchText + "') order by rank desc "; Let me know if that works.

          Harini

          M Offline
          M Offline
          Moghan
          wrote on last edited by
          #4

          Hi Harini, Its working fine now. Thank u vary much. From morning onwards i tried a lot.

          H 1 Reply Last reply
          0
          • E eyeseetee

            If

            Moghan wrote:

            ("/Software")'') where FREETEXT(contents,'" + searchText + "') order by rank desc ";

            is a new line of code then you need to put a + in the line before at the end so that it knows its the end of that line of code

            M Offline
            M Offline
            Moghan
            wrote on last edited by
            #5

            Thanks for ur reply. Harini's answer working fine.

            1 Reply Last reply
            0
            • M Moghan

              Hi Harini, Its working fine now. Thank u vary much. From morning onwards i tried a lot.

              H Offline
              H Offline
              Harini N K
              wrote on last edited by
              #6

              Ok ... That is good!!

              Harini

              1 Reply Last reply
              0
              • H Harini N K

                Hi You need to split the string "\Software" as "\"" for each double quotes with escape character: See below: cmdSearch.CommandText = "SELECT Vpath, path, FileName, size, write, attrib, Characterization, DocTitle, rank FROM SCOPE('shallow traversal of " + "\"" + "/Software" + "\"" + "') where FREETEXT(contents,'" + searchText + "') order by rank desc "; Let me know if that works.

                Harini

                H Offline
                H Offline
                Harini N K
                wrote on last edited by
                #7

                Hi, One more thing, replace the variable searchText as parameter to avoid security (SQL Injection).

                Harini N K wrote:

                cmdSearch.CommandText = "SELECT Vpath, path, FileName, size, write, attrib, Characterization, DocTitle, rank FROM SCOPE('shallow traversal of " + "\"" + "/Software" + "\"" + "') where FREETEXT(contents,'" + searchText + "') order by rank desc ";

                This is a good coding practice in any langauge.

                Harini

                M 1 Reply Last reply
                0
                • H Harini N K

                  Hi, One more thing, replace the variable searchText as parameter to avoid security (SQL Injection).

                  Harini N K wrote:

                  cmdSearch.CommandText = "SELECT Vpath, path, FileName, size, write, attrib, Characterization, DocTitle, rank FROM SCOPE('shallow traversal of " + "\"" + "/Software" + "\"" + "') where FREETEXT(contents,'" + searchText + "') order by rank desc ";

                  This is a good coding practice in any langauge.

                  Harini

                  M Offline
                  M Offline
                  Moghan
                  wrote on last edited by
                  #8

                  ok.Thanks for ur suggestion

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups