CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2007
    Posts
    68

    [RESOLVED] Storing a picture in SQL 2000

    Hi All

    I have the following code that I use to convert a picture into bytes.

    Code:
     Dim strImageFilePath As String = _ 
    LblPicture.Text 
    Dim fsImageFile As New FileStream(strImageFilePath, _ 
    FileMode.Open, FileAccess.Read) 
    Dim bytImageData(fsImageFile.Length() - 1) As Byte 
    fsImageFile.Read(bytImageData, 0, bytImageData.Length) 
    fsImageFile.Close()


    This then gets used to store into an SLQL 2000 VarBinary field.

    I thought the above would work but its only letting me save pictures that are under 8k in size, but I need to be able to save much bigger files than that.

    Any help is appreciated.

    Cheers

    Dougie
    Last edited by 1druid1; February 15th, 2010 at 06:26 AM. Reason: Answer Solved

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Storing a picture in SQL 2000

    How much bigger ¿

  3. #3
    Join Date
    Apr 2007
    Posts
    68

    Re: Storing a picture in SQL 2000

    Hi

    Thanks for the reply, the size of the picture depends on the user taking it, although I am going to teach them how to reduce picture sizes, so hopefully 1mb maximum, but the possibility of more would be good. I had written the program to use a file store instead and just link the picture via filename, but it didnt work very well as the users copied, moved deleted pictures, and refernces ended up lost. So I want to store the pictures in the database to get around this problem.

    Cheers

    Dougie

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Storing a picture in SQL 2000

    did you already see this?
    http://www.vbdotnetheaven.com/upload...sqlserver.aspx
    the type of field used to store content in Sql Server 2000 is "Image"
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  5. #5
    Join Date
    Apr 2007
    Posts
    68

    Resolved Re: Storing a picture in SQL 2000

    Thanks Cimperiali

    All I needed to do was change from a VarBinary to an Image field, I didnt even noticce the image field.

    Cheers

    Dougie

  6. #6
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: [RESOLVED] Storing a picture in SQL 2000

    you're welcome
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  7. #7
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: [RESOLVED] Storing a picture in SQL 2000

    Thought the problem may be with the size of the picture, sorry Dougie.

    Just shows, a person always think a problem is "Very complicated", but mostly isn't

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured