📄 documentdetail.aspx.vb
字号:
Imports System.Data
Imports System.Data.SqlClient
Partial Class Teacher_documentdetail
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim data() As Byte
Dim length As Integer
Dim type As String
Dim name As String
Dim db As New DBObject
Dim a As New System.Web.UI.Page
Dim cmd As New SqlCommand
cmd.Connection = db.cn
cmd.Connection.Open()
cmd.CommandText = "select * from document where documentname='" + Request.QueryString("id") + "'" '注意
Dim dr As SqlDataReader
dr = cmd.ExecuteReader()
Try
dr.Read()
data = dr("documentData")
length = dr("documentLength")
type = dr("documenttype")
name = dr("documentname")
DeliverFile(Page, data, type, length, name)
cmd.Connection.Close()
Catch ex As Exception
Response.Write("你无法查看论文!")
End Try
'With Response
' .Clear()
' .ContentType = type
' If name <> "" Then
' Page.Response.AddHeader("content-disposition", "filename=" & name)
' End If
' .OutputStream.Write(data, 0, length)
' .End()
'End With
End Sub
Public Sub DeliverFile(ByVal Page As System.Web.UI.Page, ByVal Data() As Byte, ByVal type As String, _
ByVal Length As Integer, Optional ByVal DownloadFileName As String = "")
With Page.Response
'.Clear()
.ContentType = type
If DownloadFileName <> "" Then
Page.Response.AddHeader("content-disposition", "filename=" & DownloadFileName)
End If
.OutputStream.Write(data, 0, length)
.End()
End With
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -