View Single Post
  #3 (permalink)  
Old 02-13-04, 09:49 AM
tylee tylee is offline
New Member
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Indexing Server In Asp.net

I ended up finding some code in c# for indexing server. It wasn't too difficult to convert it into vb as there isn't much code

These links should help you:

http://www.c-sharpcorner.com/Code/20...ndexServer.asp

http://www.codeproject.com/aspnet/search.asp

Here is an abstract from my code

Dim odbSearch As OleDbConnection = New OleDbConnection
Dim cmdSearch As OleDbCommand = New OleDbCommand
Dim cnt As Int64
Dim queryText As String
Dim rdrSearch As OleDbDataReader
Dim arrList As ArrayList = New ArrayList
Dim sql As String
Dim i As Int32

'assign the connecting string to the oledb connection object
odbSearch.ConnectionString = "Provider=MSIDXS.1;Data Source[catalogName]"

'assign connection to command object cmdSearch
cmdSearch.Connection = odbSearch
'Query to search a free text string in the catalog in the contents of the indexed documents in the catalog

Try

queryText = " select doctitle, filename, vpath, path, rank, characterization "
queryText &= " from scope() where FREETEXT(Contents, '" + txtSearch.Text + "') and filename <> 'FileSearching.aspx' order by rank desc "

cmdSearch.CommandText = queryText
odbSearch.Open()

Try

rdrSearch = cmdSearch.ExecuteReader()

While rdrSearch.Read
'do whatever you want to do with the results here
arrList.Add(rdrSearch.Item("filename"))
End While

Catch ex As Exception

odbSearch.Close()

End Try

Catch ex As SqlException

'lbl.Text = ex.Message.ToString()
odbSearch.Close()

End Try

'Close the connection
odbSearch.Close()
Reply With Quote