<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Using Response.Write() to display Binary data' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Using Response.Write() to display Binary data' posted on the 'ASP.NET' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2008 Programmers Heaven</copyright>
    <pubDate>Mon, 01 Dec 2008 20:22:32 -0700</pubDate>
    <lastBuildDate>Mon, 01 Dec 2008 20:22:32 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Using Response.Write() to display Binary data</title>
      <link>http://www.programmersheaven.com/mb/ASPNET/364184/364184/using-responsewrite-to-display-binary-data/</link>
      <description>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.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: Blue;"&gt;&lt;br /&gt;
    Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)&lt;br /&gt;
&lt;br /&gt;
        Dim DBConn As OdbcConnection&lt;br /&gt;
        &lt;br /&gt;
        Dim DBCommand As OdbcCommand&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        Dim DS As New DataSet&lt;br /&gt;
        If Not LBoxProfessions.SelectedItem Is Nothing Then&lt;br /&gt;
            DBConn = New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=myDB;Database=myDB;User=myUserasswo
rd=myPW;Option=3;")&lt;br /&gt;
               &lt;br /&gt;
            DBCommand = New OdbcCommand("Select ResumeID,Resumes,DocType from tb_content where Professions = '" &amp;amp; LBoxProfessions.SelectedItem.Text &amp;amp; "' Limit 10 Offset 10", DBConn)&lt;br /&gt;
&lt;br /&gt;
            DBConn.Open()&lt;br /&gt;
&lt;br /&gt;
            Dim AD As OdbcDataReader = DBCOmmand.ExecuteReader()&lt;br /&gt;
&lt;br /&gt;
            If (AD.Read()) Then&lt;br /&gt;
&lt;br /&gt;
                Dim contentLength As Integer = Convert.ToInt32(AD.GetBytes(0, 0, Nothing, 0, Integer.MaxValue))&lt;br /&gt;
                Dim buffer As Byte() = New Byte(contentLength - 1) {}&lt;br /&gt;
                AD.GetBytes(0, 0, buffer, 0, contentLength)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
              &lt;span style="color: Black;"&gt; 'Resumes is the field in the database table that holds the documents&lt;/span&gt;&lt;br /&gt;
                &lt;span style="color: Blue;"&gt;Response.AddHeader("Content-Disposition", "attachment;filename=&lt;strong&gt;Resumes&lt;/strong&gt;")&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
                &lt;span style="color: Black;"&gt;'DocType is the field that holds the mime types&lt;/span&gt;&lt;br /&gt;
                &lt;span style="color: Blue;"&gt;Response.ContentType = DirectCast(AD("&lt;strong&gt;DocType&lt;/strong&gt;"), String)&lt;br /&gt;
&lt;br /&gt;
                Response.BinaryWrite(buffer)&lt;br /&gt;
                Response.End()&lt;br /&gt;
            End If&lt;br /&gt;
            DBConn.Close()&lt;br /&gt;
        End If&lt;br /&gt;
&lt;br /&gt;
    End Sub&lt;/span&gt;&lt;br /&gt;</description>
      <pubDate>Sat, 04 Aug 2007 14:24:14 -0700</pubDate>
      <category>ASP.NET</category>
    </item>
  </channel>
</rss>