Want to see what people are talking about? See the latest forum posts.
*/
*/

Read Post

ASP.NET

Moderators: None (Apply to moderate this forum)
Number of threads: 1345
Number of posts: 2702

This Forum Only
Post New Thread

Report
Using Response.Write() to display Binary data Posted by NewWeb on on 4 Aug 2007 at 2:24 PM
Hi, I have been working on this for over two weeks and its not working. I don't know what else to do since I'm really green at this. I'm trying to display binary data from a database using Response.Write(). Please take a look to see where I went wrong, thank you in advance for your help.


Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

Dim DBConn As OdbcConnection

Dim DBCommand As OdbcCommand


Dim DS As New DataSet
If Not LBoxProfessions.SelectedItem Is Nothing Then
DBConn = New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=myDB;Database=myDB;User=myUserassword=myPW;Option=3;")

DBCommand = New OdbcCommand("Select ResumeID,Resumes,DocType from tb_content where Professions = '" & LBoxProfessions.SelectedItem.Text & "' Limit 10 Offset 10", DBConn)

DBConn.Open()

Dim AD As OdbcDataReader = DBCOmmand.ExecuteReader()

If (AD.Read()) Then

Dim contentLength As Integer = Convert.ToInt32(AD.GetBytes(0, 0, Nothing, 0, Integer.MaxValue))
Dim buffer As Byte() = New Byte(contentLength - 1) {}
AD.GetBytes(0, 0, buffer, 0, contentLength)



'Resumes is the field in the database table that holds the documents
Response.AddHeader("Content-Disposition", "attachment;filename=Resumes")

'DocType is the field that holds the mime types
Response.ContentType = DirectCast(AD("DocType"), String)

Response.BinaryWrite(buffer)
Response.End()
End If
DBConn.Close()
End If

End Sub

Reply




corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.
Resource Listings