<script runat="server">
Sub btnSearch_Click()
'create a connection object and command object, to connect the Index Server
Dim odbSearch As OleDbConnection
Dim strConnection As String = "Provider=\'MSIDXS\';Data Source=\'my_search\';"
Dim searchtext = txtSearch.Text.Replace("'","''")
Dim strSelection As String = "select doctitle, filename, vpath, rank, characterization from scope() where FREETEXT(Contents, '" + searchtext + "') order by rank desc "
Dim cmdSearch As OleDbDataAdapter
odbSearch = New OleDbConnection(strConnection)
cmdSearch = New OleDbDataAdapter(strSelection, odbSearch)
End Sub
</script>
<body>
<form runat="server">
Enter your search query:
<asp:TextBox id="txtSearch" runat="server"/>
Member
11 Points
52 Posts
Connceting to Windows index file (2008 server)
Feb 03, 2011 10:05 PM|Paulnk101|LINK
I am trying to create a search box on my website. I turned on the index service for windows.
When I run the page below I get this error:
Format of the initialization string does not conform to specification starting at index 0.
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="utf-8" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Web.UI.Page" %>
<script runat="server">
Sub btnSearch_Click()
'create a connection object and command object, to connect the Index Server
Dim odbSearch As OleDbConnection
Dim strConnection As String = "Provider=\'MSIDXS\';Data Source=\'my_search\';"
Dim searchtext = txtSearch.Text.Replace("'","''")
Dim strSelection As String = "select doctitle, filename, vpath, rank, characterization from scope() where FREETEXT(Contents, '" + searchtext + "') order by rank desc "
Dim cmdSearch As OleDbDataAdapter
odbSearch = New OleDbConnection(strConnection)
cmdSearch = New OleDbDataAdapter(strSelection, odbSearch)
End Sub
</script>
<body>
<form runat="server">
Enter your search query:
<asp:TextBox id="txtSearch" runat="server"/>
<asp:Button
id="btnSearch"
runat="server"
Text="Search"
OnCommand="btnSearch_Click"
CommandName="search"
/>
<hr>
<asp:Repeater id="searchResults" runat="server">
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "File") %> <br>
<%# DataBinder.Eval(Container.DataItem, "FileAbstract") %> <br>
</ItemTemplate>
<SeparatorTemplate><br></SeparatorTemplate>
</asp:Repeater>
</form>
Walk by faith not by sight
II Corinthians 5:7
Star
10830 Points
2409 Posts
Re: Connceting to Windows index file (2008 server)
Feb 04, 2011 06:47 AM|shabirhakim1|LINK
Hi,
You can see here
This Error Appears: Format of the initialization string does not ...
Regards
shabir