Click here to Skip to main content
15,896,496 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello, I am using example code that works to display the contents of the Microsoft Index Service on our 2008 R2 File Server running iis8. Problem is, I need to use the Replace function to replace the "C:" and the "\" characters with "http://" and "/" in the path to work with the Intranet. I can't seem to figure out how to do that as I continue to get errors and knowing nothing about this language, I have been reading for days and can find nothing. I'm wishing I would have just started to learn the entire language instead of polluting my mind with all the bits and pieces. HELP PLEASE!!! Thank you in advance, Bill


Here is the VB code:

VB
Imports System.Data

Partial Class _WebForm1
    Inherits System.Web.UI.Page

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim strCatalog As String

        ' Catalog Name
        strCatalog = "IIS_Index"

        Dim strQuery As String
        strQuery = "Select DocTitle,Filename,Create,Size,Path,URL from SCOPE() where FREETEXT('" & TextBox1.Text & "')"
    Dim connString As String = "Provider=MSIDXS.1;Integrated Security .='';Data Source='" & strCatalog & "'"

        Dim cn As New System.Data.OleDb.OleDbConnection(connString)
        Dim cmd As New System.Data.OleDb.OleDbDataAdapter(strQuery, cn)
        Dim testDataSet As New DataSet()

        cmd.Fill(testDataSet)

        ' Bind DataGrid to the DataSet. DataGrid is the ID for the
        ' DataGrid control in the HTML section.
        Dim source As New DataView(testDataSet.Tables(0))
        DataGrid1.DataSource = source
        DataGrid1.DataBind()
    End Sub
End Class


Here is the HTML

ASP.NET
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="search.aspx.vb" Inherits="_WebForm1"debug="true" %>

<HTML>
<HEAD>
<title>Intranet Index Services</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">

</HEAD>
<body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
        <asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 238px; POSITION: absolute; TOP: 76px" runat="server"></asp:TextBox>
        <asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 25px; POSITION: absolute; TOP: 145px" runat="server" AutoGenerateColumns="False">

    <Columns>
        <asp:BoundColumn DataField="DocTitle" HeaderText="DocTitle"></asp:BoundColumn>
        <asp:BoundColumn DataField="filename" HeaderText="FileName"></asp:BoundColumn>
	<asp:BoundColumn DataField="Create" HeaderText="Create"></asp:BoundColumn>
        <asp:BoundColumn DataField="size" HeaderText="Size"></asp:BoundColumn>
        <asp:BoundColumn DataField="path" HeaderText="PATH"></asp:BoundColumn>
	<asp:BoundColumn DataField="url" HeaderText="URL "></asp:BoundColumn>
    </Columns>
		</asp:DataGrid>
<asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 400px; POSITION: absolute; TOP: 100px" runat="server" Text="Button"></asp:Button>
<hr style="Z-INDEX: 104; LEFT: 0px; POSITION: absolute; TOP: 140px">
</form>
</body>
</HTML>
Posted

1 solution

1. You can do the replace when you select data from your data source by writing replace sql in your select statement. but in oledb replace function not available, so you may need to implement replace using InStr() and Len() functions.

2. You can change the dataset or datatable column values by using simple for loop and change the values using string replace[^]. then bind the updated datatable to your gridview

3. you can use RowDataBound Event of your GridView and change set the cell value after replacing. check this [^] answer and modify according to your needs.

I haven't provide direct answer to your question, you need to try your self and find your own solution. in case of issue you better ask question with what you have tried and where you stuck. good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900