Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2002
    Posts
    1,245

    Unanswered: Download Documents From Database

    Does anyone have a code snippet in VBScript for how allow a user to save (or open) a document that has been stored in a database?

    I have documents that are stored in an image column in a database. I have the code I need to upload documents from a user's browser. I'm not having any luck, however, figuring out how to let the user view or download the document that has been stored.

    Regards,

    Hugh Scott

  2. #2
    Join Date
    Aug 2002
    Location
    Scotland
    Posts
    1,578
    I'm no developer but found interesting code snippets from Planet SC.

    HTH
    --Satya SKJ
    Microsoft SQL Server MVP
    [IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]

  3. #3
    Join Date
    Dec 2002
    Posts
    1,245

    Re: Download Documents From Database

    Sorry,

    I had the code snippet right under my nose. This is VBScript:
    Code:
    <%
      Set Conn = GetConnection 
      Set adoRS = Server.CreateObject("ADODB.Recordset")
    
      'Open dynamic recordset, table Upload
      adoRS.Open "SELECT * FROM tbl_Documents WHERE DocumentID = 1", Conn, 2, 2
    
      sFileName = adoRS("SourceFileName")
      sContentType = adoRS("ContentType")
      sDataSize = adoRS("DataSize")
    
    
    ' clear the buffer
    		Response.Buffer = True
    		Response.Clear
    		
    		
    		' send the headers to the users browser
    		Response.AddHeader "Content-Disposition", "attachment; filename=" & sFileName
    		' Response.AddHeader "Content-Length", sDataSize
    		Response.Charset = "UTF-8"
    		Response.ContentType = scontentType
    		
    		' output the file to the browser
    		Response.BinaryWrite adoRS("Data")
    		Response.Flush
    		
    		
    		' tidy up
    		s.Close
    		Set s = Nothing
    
    
    Function GetConnection()
      dim Conn
    
      Set Conn = CreateObject("ADODB.Connection")
    
      Conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=iEIC;Data Source=MyServer"
    
      Conn.Open
    
      set GetConnection = Conn
    end function
    %>

    Originally posted by hmscott
    Does anyone have a code snippet in VBScript for how allow a user to save (or open) a document that has been stored in a database?

    I have documents that are stored in an image column in a database. I have the code I need to upload documents from a user's browser. I'm not having any luck, however, figuring out how to let the user view or download the document that has been stored.

    Regards,

    Hugh Scott

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •