SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,877
    Mentioned
    46 Post(s)
    Tagged
    0 Thread(s)

    Storing an image in SQL Server 2000

    Hey guys

    I need to create a DB in SQL that has a field called image and that column should hold the actually image. Problem is i dnt no how 2 do this.

    What should the column type be? And then how do i actually put the image in the db from my HDD?

    Personally i dnt think its a gud idea to store the whole image in a db, coz the db is gona get to big. I would normally just store the path, but hey my boss wants the image in the db. hehehe

    Thanks guys

  2. #2
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Images stored in a database are strored as BLOB

    however as said by you, it could be a bad design especially when you start to scale. I recommend you store your images in a folder and use a pointer in your db, to point to it. As
    Code:
    <img src="<%=(images1.Fields.Item("images").Value)%>.gif">

    or for a relative path use

    Code:
    <img src="../images/images/<%=(images1.Fields.Item("images").Value)%>.gif">
    replace gif with jpg depending on what image type you use

    And replace ../images/images/ with your image source

    rgds
    Afrika

  3. #3
    SitePoint Guru puco's Avatar
    Join Date
    Feb 2005
    Location
    Slovakia
    Posts
    785
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Storing images, large text/binary data in MS SQL is slower than storing them on filesystem (inserting and selecting). So I would store them on FS and put only path to DB. You should also consider a multilevel storage of the files, becasue I don't think it is very healthy to have 1M file system objects in one folder. For this you can use some hash function.
    Martin Pernecky


Bookmarks

Posting Permissions

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