PC Review


Reply
Thread Tools Rate Thread

Displaying binary data

 
 
James Page
Guest
Posts: n/a
 
      4th Mar 2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change binary data buffer read from a binary file to string format Anderson Microsoft VC .NET 1 21st Jul 2006 11:35 AM
displaying images on a website from binary =?Utf-8?B?Q0xFQVItUkNJQw==?= Microsoft Dot NET 3 27th Jan 2006 06:56 PM
displaying binary data =?Utf-8?B?TWFubnkgQ2hvaGFu?= Microsoft ASP .NET 2 6th Dec 2005 12:24 AM
Displaying Binary Data =?Utf-8?B?Sm9obiBMYW5l?= Microsoft Access VBA Modules 1 2nd Dec 2004 10:02 PM
Displaying Long Binary Data in a Report =?Utf-8?B?Sm9obiBEb3VnaGVydHk=?= Microsoft Access Reports 6 29th Apr 2004 01:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:19 AM.