• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

How to make a file to be downloaded ..?

Need to do the show the file from db ,

 i have the file in the folder  and that filename inthe table ,

 how can i show that file to be downloadable .
this below CODE brings the FILENAME ...

but "couldnt" able to show the file ,

so that the user can download ....
plz suggest..?

Public Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
        con = New SqlConnection(ConfigurationSettings.AppSettings("str1"))
      cmd= New SqlCommand("Single_Date", con)
        cmd.CommandType = CommandType.StoredProcedure
        Dim parameter_Date As New SqlParameter("@_Date", SqlDbType.DateTime, 8)
        parameter_Date.Value = Calendar1.SelectedDate
        myDataReader = myCommand.ExecuteReader()
        Dim temp As String = ""
        'Dim Category As String
        Dim diffdbdate As DateTime
        While (myDataReader.Read())
            diffdbdate = myDataReader.Item("startdate")
            If (myDataReader.Item("freeregreq") = 1 And myDataReader.Item("escrow") = 1) Then
                temp &= "<br>name  :" & myDataReader.Item("cname") & "<br>Filedownload: " & myDataReader.Item("files") & ""
            End If
        End While
        Label1.Text = temp
    End Sub

Open in new window

Rajar Ahmed
Rajar Ahmed
  • 3
2 Solutions
Ken FayalCommented:
You should put the file name in <A HREF> tags so that it will show as a link, but you have to provide the full path to the file.
Rajar AhmedConsultantAuthor Commented:
I dint see the file name  and there is a link field which shows url f:/projext/filesfilename.txt on the status bar..
temp &= "<br>name  :" & myDataReader.Item("cname") & "<br>Filedownload: <a href=""F:\projext\files" & myDataReader.Item("files") & """>"

Rajar AhmedConsultantAuthor Commented:
temp &= "<br>name  :" & myDataReader.Item("cname") & "<br>Filedownload: <a href=""http://F:/projext/files/t"">" & myDataReader.Item("files") & "</a>"

this is transfering the page to this url and loading the cannot open page rather than downloading the file
meeran03, do you have the folder as a virtual path? if so, then the http address with the location is sufficient.  You just need to append the file name from the db to the virtual path and assign it to the href of the hyperlink as
     temp &= "<br>name  :" & myDataReader.Item("cname") & "<br>Filedownload: <a href='http://projext/files/t/" & myDataReader.Item("files") & "'>" & myDataReader.Item("files") & "</a>"
assuming http://projext/files/t/ as your virtual path.

But, if you have the file in a shared location or in the file system, that do not have the virtual path then refer http://www.xefteri.com/articles/show.cfm?id=8
Rajar AhmedConsultantAuthor Commented:
thanks .. i created the virtual path and did...

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now