Based on the name vpath would be likely some kind of virtual directory
(perhaps when you index content on another server using a share ?). So path
should do it if you are on the same server...
Got it. Almost done, however, when I release my new awesome search
page to the web server the Next Page linkbutton doesn't work; it
returns an error listed below. The code does work on my local
computer while debugging but does not work on the web server. Ever
had this problem? I don't use the ViewState much so I may need to
read up on that.... Just thought I would post in case you have ever
had this same issue.
Server Error in '/' Application: Index was out of range. Must be non-
negative and less than the size of the collection.
Parameter name: index
Example Code:
Public Class Library
Inherits System.Web.UI.Page
Protected values As New ArrayList()
Public cnt As Integer
Public Property CurrentPage() As Integer
Get
Dim o As Object = Me.ViewState("_CurrentPage")
' look for current page in ViewState
If o Is Nothing Then
Return 0
Else
' default to showing the first page
Return CInt(o)
End If
End Get
Set(ByVal value As Integer)
Me.ViewState("_CurrentPage") = value
End Set
End Property
Protected Sub cmdNext_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdNext.Click
' Set viewstate variable to the next page
CurrentPage += 1
' Reload control
btnSearch_Click(sender, e)
End Sub
'Execute the search
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSearch.Click
''Reset to page 1 as a new search is performed
If sender.text.ToString = "search" Then
CurrentPage = 0
End If
' Show Prev or Next buttons upon searching
cmdPrev.Visible = True
cmdNext.Visible = True
cnt = 1
If btntxtSearch.Text.Trim() = "" Then
btnClear_Click(sender, e)
Else
lbl.Text = ""
Search()
End If
End Sub
Public Sub Search()
Dim iPos As Integer
'create a connection object and command object, to connect the
Index Server
Dim odbSearch As New
System.Data.OleDb.OleDbConnection("Provider=""MSIDXS"";Data
Source=""Library"";")
Dim cmdSearch As New System.Data.OleDb.OleDbCommand()
'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
Dim searchText As String = btntxtSearch.Text.Replace("'",
"''")
cmdSearch.CommandText = "select doctitle, filename, vpath,
rank, characterization from scope() where FREETEXT(Contents, '" &
searchText & "') order by rank desc"
odbSearch.Open()
Try
'execute search query
Dim rdrSearch As System.Data.OleDb.OleDbDataReader =
cmdSearch.ExecuteReader()
'loop through each result and bind it to the repeater
control
While rdrSearch.Read()
'Assemble the search result text and abstract
getpagelink(rdrSearch(0).ToString(),
rdrSearch(2).ToString(), rdrSearch(4).ToString())
End While
Catch ex As Exception
lbl.Text = "Search Error: " & ex.Message & "<br>"
End Try
odbSearch.Close()
' Populate the repeater control with the Items DataSet
Dim objPds As New PagedDataSource()
objPds.DataSource = values
' Indicate that the data should be paged
objPds.AllowPaging = True
' Set the number of items you wish to display per page
objPds.PageSize = 50
' Set the PagedDataSource's current page
objPds.CurrentPageIndex = CurrentPage
'Display a summary for the current search
resultSummary.Text = ((("Your search for <b>" &
btntxtSearch.Text & "</b> Returned ") & (cnt - 1) & " Results. " &
"<br>Page: ") & (CurrentPage + 1).ToString() & " of ") &
objPds.PageCount.ToString()
' Disable Prev or Next buttons if necessary
cmdPrev.Enabled = Not objPds.IsFirstPage
cmdNext.Enabled = Not objPds.IsLastPage
repSearchResults.DataSource = objPds
repSearchResults.DataBind()
End Sub
End Class