Uploading Docs Into Sql Server

Discussion in 'ASP .Net' started by Guest, Oct 18, 2006.

  1. Guest

    Guest Guest

    Can someone offer or point me to some sample code or advice on how to upload a document from a web page and store it into a SQL Server image field? And then reverse the process and serve up the file from the database when requested through a web page...

    Thanks.

    Jerry
     
    Guest, Oct 18, 2006
    #1
    1. Advertising

  2. Guest

    Mark Rae Guest

    <> wrote in message
    news:...

    > Can someone offer or point me to some sample code or advice on how to
    > upload a document
    > from a web page and store it into a SQL Server image field? And then
    > reverse the process and
    > serve up the file from the database when requested through a web page...


    Google is your friend - there are loads of articles and code samples
    available:
    http://www.google.co.uk/search?sour...06-28,GGLG:en&q="SQL Server" web binary store
     
    Mark Rae, Oct 18, 2006
    #2
    1. Advertising

  3. Guest

    Superman Guest

    Jerry,

    1. Uploading is simple for the actual file uploading piece.

    Use the <asp:htmlfileinput /> control and when the page posts use the
    ..PostedFile.SaveAs(stream) method to save it. Use a SqlCommand and add
    a parameter, set it's type to SqlDbType.Image.

    2. Retrieving the data is relatively simple, fill your dataset and
    extract the column as you would any other column. Cast it to whatever
    you need...

    variable = (byte[])dataset.Tables[0][x];

    HTH,

    -Brenton MCSD.NET

    am wrote:
    > Can someone offer or point me to some sample code or advice on how to upload a document from a web page and store it into a SQL Server image field? And then reverse the process and serve up the file from the database when requested through a web page...
    >
    > Thanks.
    >
    > Jerry
    > ------=_NextPart_000_0006_01C6F298.D1098290
    > Content-Type: text/html; charset=iso-8859-1
    > Content-Transfer-Encoding: quoted-printable
    > X-Google-AttachSize: 807
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > <HTML><HEAD>
    > <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
    > <META content="MSHTML 6.00.5700.6" name=GENERATOR>
    > <STYLE></STYLE>
    > </HEAD>
    > <BODY bgColor=#ffffff>
    > <DIV><FONT face=Arial size=2>Can someone offer or point me to some sample code
    > or advice on how to upload a document from a web page and store it into a SQL
    > Server image field?&nbsp; And then reverse the process and serve up the file
    > from the database when requested through a web page...</FONT></DIV>
    > <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    > <DIV><FONT face=Arial size=2>Thanks.</FONT></DIV>
    > <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    > <DIV><FONT face=Arial size=2>Jerry</FONT></DIV></BODY></HTML>
    >
    > ------=_NextPart_000_0006_01C6F298.D1098290--
     
    Superman, Oct 18, 2006
    #3
  4. Hi Jerry,

    For Uploading file in ASP.NET, there are many tech article describing this:

    #How to upload a file to a Web server in ASP.NET by using Visual Basic .NET
    http://support.microsoft.com/kb/323245/en-us

    #ASP.NET 2.0 FileUpload Server Control
    http://www.codeguru.com/dbfiles/get_avatar.php?id=183439

    Also, the following article has demonstrate store the uploaded file content
    into database binary data table column:

    #File Upload with ASP.NET
    http://www.codeproject.com/aspnet/fileupload.asp


    In addition, for reading and retrieveing binary/image data in SQL Server,
    they're pure ADO.NET data accessing tasks and here are some good article
    demonstrate this:


    #Storing and Retrieving Images from SQL Server using Microsoft .NET
    http://www.codeproject.com/cs/database/ImageSaveInDataBase.asp

    #Utilize ADO.NET and C# to work with BLOB data
    http://builder.com.com/5100-6371_14-5766889.html


    Hope this helps.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    ==================================================

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.



    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.

    ==================================================



    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Oct 19, 2006
    #4
  5. hello,
    if you're using C# 2.0 then try the web control FileUpload which has SaveAs
    method...
    hope it'll help

    "" wrote:

    > Can someone offer or point me to some sample code or advice on how to upload a document from a web page and store it into a SQL Server image field? And then reverse the process and serve up the file from the database when requested through a web page...
    >
    > Thanks
     
    =?Utf-8?B?T3Jlbg==?=, Oct 19, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KYG
    Replies:
    2
    Views:
    949
    Ian Collins
    Aug 18, 2008
  2. gga
    Replies:
    5
    Views:
    106
    Eric Hodel
    Jan 18, 2007
  3. Stéphane Wirtel
    Replies:
    0
    Views:
    207
    Stéphane Wirtel
    Apr 19, 2007
  4. Al
    Replies:
    1
    Views:
    165
    Henry Law
    Oct 16, 2005
  5. Irmen de Jong

    problem uploading docs to pypi

    Irmen de Jong, Jun 14, 2013, in forum: Python
    Replies:
    2
    Views:
    92
    Irmen de Jong
    Jun 15, 2013
Loading...

Share This Page