日期:2014-05-17 浏览次数:20501 次
<%@ Page Language="C#" CodeBehind="Default.aspx.cs" AutoEventWireup="false" Inherits="IndexService08._Default" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <html> <head> <title>WebForm3</title> <meta name="GENERATOR" content ="Microsoft Visual Studio 7.0"> <meta name="CODE_LANGUAGE" content ="C#"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </head> <body MS_POSITIONING="GridLayout"> <form id="WebForm3" method="post" runat="server"> <asp:DataGrid id="DataGrid1" style=" z-index : 102; left : 326px; position : absolute; top : 141px; width:auto;" runat="server"></asp:DataGrid> <asp:Button id="Button1" style=" z-index : 103; left : 92px; position : absolute; top : 199px; right: 806px;" runat="server" Text="Button" onclick="Button1_Click"></asp:Button> <asp:TextBox id="TextBox1" style=" z-index : 101; left : 90px; position : absolute; top : 136px" runat="server"></asp:TextBox> <asp:Label ID="Label1" runat="server" Text=""></asp:Label> <p> <asp:GridView ID="GridView1" runat="server" style=" z-index : 103; left : 92px; position : absolute; top : 280px; right: 806px; width:auto " runat="server"> </asp:GridView> </p> <asp:TextBox ID="txtPath" runat="server"></asp:TextBox> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; namespace IndexService08 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string strCatalog = "ShareFiles";//"TestCatalog"; string strQuery = ""; strQuery = "Select Filename,Size,Directory,Write,Path from Scope() where FREETEXT('" + TextBox1.Text + "')"; string connstring = "Provider=MSIDXS.1;Integrated Security .='';Data Source=" + strCatalog; System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connstring); conn.Open(); System.Data.OleDb.OleDbDataAdapter cmd = new System.Data.OleDb.OleDbDataAdapter(strQuery, conn); System.Data.DataSet testDataSet = new System.Data.DataSet(); cmd.Fill(testDataSet, "SearchResults"); DataView source = new DataView(testDataSet.Tables[0]); //DataGrid1.DataSource = source; //DataGrid1.DataBind(); this.GridView1.DataSource = source; this.GridView1.DataBind(); conn.Close();