Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 765329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:52:22+00:00 2026-05-14T16:52:22+00:00

I have a binary file in database. How i can make a download of

  • 0

I have a binary file in database.
How i can make a download of this file in header of page when a button is clicked

Any ideas??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T16:52:23+00:00Added an answer on May 14, 2026 at 4:52 pm

    Alright, there’s a couple of things you might be trying to do, its not completely clear but I’ll take a stab at it. Let’s say you’ve got the following basic database comprised of a file identifier and the binary file information:

    CREATE TABLE Test
    (
    FileId int identity(1,1) PRIMARY KEY,
    FileData varBinary(max)
    )
    

    What you need is a page (in this case called “GetFile.aspx”) with the following in the the code-behind’s Page_Load event:

        'Make sure we've got a querystring
        If String.IsNullOrEmpty(Request.QueryString("fileid")) Then
            Throw New ApplicationException("Missing querystring parameter FileId")
        End If
        Dim FileId As Integer
        'Make sure the querystring is an Int
        If Not Integer.TryParse(Request.QueryString("fileid"), FileId) Then
            Throw New ApplicationException("Malformed querystring parameter FileId")
        End If
        'Change YourDsnHere to point to your database
        Using Con As New SqlConnection("YourDsnHere")
            Con.Open()
            'Select the file
            Using Com As New SqlCommand("SELECT * FROM Test WHERE FileId=@FileId", Con)
                Com.CommandType = Data.CommandType.Text
                Com.Parameters.AddWithValue("@FileId", FileId)
                Using RDR = Com.ExecuteReader()
                    If RDR.Read Then
                        'Get the data out as a byte array
                        Dim Bytes() = DirectCast(RDR.Item("FileData"), Byte())
                        'Clear all response headers
                        Response.Clear()
                        'Set the type, my sample is a RAR file, you'll need to look up MIME types for yours
                        Response.AddHeader("Content-Type", "application/x-rar-compressed")
                        'Set the name of the file, if you don't set it browsers will use the name of this page which you don't want
                        Response.AddHeader("Content-Disposition", "inline; filename=YourFilenameHere.rar")
                        'Optional but nice, set the length so users get a progress bar
                        Response.AddHeader("Content-Length", Bytes.Count.ToString())
                        'Push the bytes out raw
                        Response.BinaryWrite(Bytes)
                        'Close the response stream so no more HTML gets accidentally pushed out
                        Response.End()
                    Else
                        'Error, no file was found
                    End If
                End Using
            End Using
            Con.Close()
        End Using
    

    Then in your page just when the person clicks the button direct them to this page making sure to pass a valid fileid in the querystring.

    Like I said, I think this is what you’re looking for, if not, clarify your description above

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a binary file that I need to insert a header at the
I'm trying to save a binary file stored in a SQL database with a
i have to save a file in any format (XLS, PDF, DOC, JPG ....)
hello i have tryed a lot of source codes for this but i have
Similar questions: Some characters in CSV file are not read during PHP fgetcsv() ,
I have a Java Applet that is generating an image. Ultimately, I would like
In the following scenario: I got a project having a catalog of currently some
I am using a trigger on a table to send an email using sp_send_dbmail.
I am getting confused as to what is the difference between the compiler and
Given an installer generated with a VS2010 Setup Project, I would like to swap

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.