Displaying binary data

J

James Page

I have a asp.net 2.0 web page that retrieves binary data from an SQL server
2005 database - varBinary(MAX). I'm storing .pdf files, .txt files & .doc
files here is the code:
Imports System.Data.SqlClient

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

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim FileID As Integer = Convert.ToInt32(Request.QueryString("id"))


Using myConnection As New
SqlConnection(ConfigurationManager.ConnectionStrings("ACMEConnectionString").ConnectionString)

Const SQL As String = "SELECT [documentMimeType], [documentFile]
FROM [acmeDocuments] WHERE [prodId] = @prodId"
Dim myCommand As New SqlCommand(SQL, myConnection)
myCommand.Parameters.AddWithValue("@prodId", FileID)

myConnection.Open()

Dim myReader As SqlDataReader = myCommand.ExecuteReader
If myReader.Read Then
Response.ContentType = myReader("documentMimeType").ToString()
'"application/pdf"
Response.BinaryWrite(myReader("documentFile"))
End If
myReader.Close()
myConnection.Close()
End Using
End Sub

End Class

My question is - if the client machine does not have, for example, pdf
viewer software installed, is there anyway i can ascertain they do not have
the right software installed and direct them to a page giving instructions
etc,. before the showFile.aspx page is displayed - as if the client machine
does not have the software installed they are asked to open or save the .aspx
page which defeats the object somewhat!

Your comments would be useful.

Thanks

James
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,965
Messages
2,570,148
Members
46,710
Latest member
FredricRen

Latest Threads

Top