Imports System.Data.OleDb

Partial Public Class _Default
    Inherits System.Web.UI.Page

    Protected text As String

    '从数据库中读取文件列表
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim connStr As String
        connStr = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" & Server.MapPath("App_Data/database.mdb")

        Dim conn As OleDbConnection = New OleDbConnection(connStr)
        Dim da As OleDbDataAdapter = New OleDbDataAdapter("select * from T_Files order by FileDate desc", conn)

        Try
            Dim dt As DataTable = New DataTable()
            Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder
            da.Fill(dt)
            For Each row In dt.Rows
                sb.AppendLine("<li><a href='UdPdf.aspx?Id=" & row("Id").ToString() & "' target='_blank'>" & row("FileName").ToString() & "</a></li>")
            Next
            text = "<ul>" & sb.ToString() & "</ul>"
        Catch ex As Exception
            Response.Write("<font color='red'>读取数据库失败：" & ex.Message & "</font>")
        End Try
    End Sub

End Class