Storing Images in SQL Server - ASP storage and retrieve

Discussion in 'ASP General' started by Michael Walton, Dec 30, 2003.

  1. I need some help, because I am utterly confused with how to do this. I have
    2 things that I need to figure out, and could use some sample code or just
    some general direction:

    1) I need to build an admin page that allows me to browse to the file that I
    want stored in SQL Server 2000 in an image field, have it uploaded to the
    server, and then stored in the db. I see this done all the time, so I don't
    think this part is too hard, but I'm not sure how to get the image into the
    db.

    2) I want to display the image within a web page, so I would want to pull
    the image out of the db, place it on my web server in a certain location,
    and then reference the file in the HTML. How do I do that?

    Thanks in advance for any help you can provide.

    --Mike
     
    Michael Walton, Dec 30, 2003
    #1
    1. Advertising

  2. Michael Walton

    Foo Man Chew Guest

    Why do you want to store the image in the database? This article really
    helped me decide which way to go on this, and I'm glad I didn't use the
    database for file storage after I've seen the headaches it's caused some of
    my colleagues.

    http://www.aspfaq.com/show.asp?id=2149

    There are also links to knowledge base articles that show a few different
    methods, with code samples, if it's really what you want to do. But I
    highly recommend you reconsider.


    "Michael Walton" <> wrote in message
    news:...
    > I need some help, because I am utterly confused with how to do this. I

    have
    > 2 things that I need to figure out, and could use some sample code or just
    > some general direction:
    >
    > 1) I need to build an admin page that allows me to browse to the file that

    I
    > want stored in SQL Server 2000 in an image field, have it uploaded to the
    > server, and then stored in the db. I see this done all the time, so I

    don't
    > think this part is too hard, but I'm not sure how to get the image into

    the
    > db.
    >
    > 2) I want to display the image within a web page, so I would want to pull
    > the image out of the db, place it on my web server in a certain location,
    > and then reference the file in the HTML. How do I do that?
    >
    > Thanks in advance for any help you can provide.
    >
    > --Mike
    >
    >
     
    Foo Man Chew, Dec 30, 2003
    #2
    1. Advertising

  3. I normally just store images on the directory structure, but I am having a
    real hard maintaining this in the environment that I am in. We have many,
    many authors and they keep moving images, deleting images, renaming images,
    and I end up with broken images, so I'd rather take care of it through the
    ASP code, so they can't screw it up. I will check the link, though.

    "Foo Man Chew" <> wrote in message
    news:...
    > Why do you want to store the image in the database? This article really
    > helped me decide which way to go on this, and I'm glad I didn't use the
    > database for file storage after I've seen the headaches it's caused some

    of
    > my colleagues.
    >
    > http://www.aspfaq.com/show.asp?id=2149
    >
    > There are also links to knowledge base articles that show a few different
    > methods, with code samples, if it's really what you want to do. But I
    > highly recommend you reconsider.
    >
    >
    > "Michael Walton" <> wrote in message
    > news:...
    > > I need some help, because I am utterly confused with how to do this. I

    > have
    > > 2 things that I need to figure out, and could use some sample code or

    just
    > > some general direction:
    > >
    > > 1) I need to build an admin page that allows me to browse to the file

    that
    > I
    > > want stored in SQL Server 2000 in an image field, have it uploaded to

    the
    > > server, and then stored in the db. I see this done all the time, so I

    > don't
    > > think this part is too hard, but I'm not sure how to get the image into

    > the
    > > db.
    > >
    > > 2) I want to display the image within a web page, so I would want to

    pull
    > > the image out of the db, place it on my web server in a certain

    location,
    > > and then reference the file in the HTML. How do I do that?
    > >
    > > Thanks in advance for any help you can provide.
    > >
    > > --Mike
    > >
    > >

    >
    >
     
    Michael Walton, Dec 30, 2003
    #3
  4. Simpler isn't always best, unfortunately. Like I told Foo Man Chew, I have
    control issues with the images being on the directory structure, so I need
    to look into db methods. Thanks for the opinion, though (and I agree with
    it).


    "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
    news:...
    > 1) Actually it's not a good idea. Upload the image to the server and store
    > the Name/Location in the DB. look at www.darkfalz.com/1043 for a simple
    > upload script.
    >
    > 2) Much simplier if you have the image on the server.... :}
    >
    > --
    > Curt Christianson
    > Owner/Lead Developer, DF-Software
    > www.Darkfalz.com
    >
    >
    > "Michael Walton" <> wrote in message
    > news:...
    > > I need some help, because I am utterly confused with how to do this. I

    > have
    > > 2 things that I need to figure out, and could use some sample code or

    just
    > > some general direction:
    > >
    > > 1) I need to build an admin page that allows me to browse to the file

    that
    > I
    > > want stored in SQL Server 2000 in an image field, have it uploaded to

    the
    > > server, and then stored in the db. I see this done all the time, so I

    > don't
    > > think this part is too hard, but I'm not sure how to get the image into

    > the
    > > db.
    > >
    > > 2) I want to display the image within a web page, so I would want to

    pull
    > > the image out of the db, place it on my web server in a certain

    location,
    > > and then reference the file in the HTML. How do I do that?
    > >
    > > Thanks in advance for any help you can provide.
    > >
    > > --Mike
    > >
    > >

    >
    >
     
    Michael Walton, Dec 30, 2003
    #4
  5. Michael Walton

    Curt_C [MVP] Guest

    1) Actually it's not a good idea. Upload the image to the server and store
    the Name/Location in the DB. look at www.darkfalz.com/1043 for a simple
    upload script.

    2) Much simplier if you have the image on the server.... :}

    --
    Curt Christianson
    Owner/Lead Developer, DF-Software
    www.Darkfalz.com


    "Michael Walton" <> wrote in message
    news:...
    > I need some help, because I am utterly confused with how to do this. I

    have
    > 2 things that I need to figure out, and could use some sample code or just
    > some general direction:
    >
    > 1) I need to build an admin page that allows me to browse to the file that

    I
    > want stored in SQL Server 2000 in an image field, have it uploaded to the
    > server, and then stored in the db. I see this done all the time, so I

    don't
    > think this part is too hard, but I'm not sure how to get the image into

    the
    > db.
    >
    > 2) I want to display the image within a web page, so I would want to pull
    > the image out of the db, place it on my web server in a certain location,
    > and then reference the file in the HTML. How do I do that?
    >
    > Thanks in advance for any help you can provide.
    >
    > --Mike
    >
    >
     
    Curt_C [MVP], Dec 30, 2003
    #5
  6. Michael Walton

    Foo Man Chew Guest

    > 2) I want to display the image within a web page, so I would want to pull
    > the image out of the db, place it on my web server in a certain location,
    > and then reference the file in the HTML.


    Read that sentence a couple of times, and think about how efficient that is
    compared to <img src=/images/uploadedImage.jpg>
     
    Foo Man Chew, Dec 30, 2003
    #6
  7. Right - I totally understand. However, when that image isn't there, because
    dumb-idiot content developer has moved it or deleted it, how efficient is
    the empty image with the red x in it?? I totally understand what I am
    asking, and unless you have a better way to control the images on the
    server, I have to use the DB to do it. This will take the control away from
    the content developer and put it back into my hands. Trust me....the way
    you are telling to do it is the way I've done it for 10 years, but its not
    working in this environment, because of the morons I'm dealing with.

    --Mike

    "Foo Man Chew" <> wrote in message
    news:...
    > > 2) I want to display the image within a web page, so I would want to

    pull
    > > the image out of the db, place it on my web server in a certain

    location,
    > > and then reference the file in the HTML.

    >
    > Read that sentence a couple of times, and think about how efficient that

    is
    > compared to <img src=/images/uploadedImage.jpg>
    >
    >
     
    Michael Walton, Dec 30, 2003
    #7
  8. Thanks, Foo. That link had some good information in it, as well as links
    with great examples. Exactly what I was looking for.

    I also appreciate the opinions that are out there....if I could do it that
    way, I would continue to do so, but until they start hiring intelligent
    people (or intelligent people start breeding), I'm stuck with this.

    --Mike

    "Foo Man Chew" <> wrote in message
    news:...
    > Why do you want to store the image in the database? This article really
    > helped me decide which way to go on this, and I'm glad I didn't use the
    > database for file storage after I've seen the headaches it's caused some

    of
    > my colleagues.
    >
    > http://www.aspfaq.com/show.asp?id=2149
    >
    > There are also links to knowledge base articles that show a few different
    > methods, with code samples, if it's really what you want to do. But I
    > highly recommend you reconsider.
    >
    >
    > "Michael Walton" <> wrote in message
    > news:...
    > > I need some help, because I am utterly confused with how to do this. I

    > have
    > > 2 things that I need to figure out, and could use some sample code or

    just
    > > some general direction:
    > >
    > > 1) I need to build an admin page that allows me to browse to the file

    that
    > I
    > > want stored in SQL Server 2000 in an image field, have it uploaded to

    the
    > > server, and then stored in the db. I see this done all the time, so I

    > don't
    > > think this part is too hard, but I'm not sure how to get the image into

    > the
    > > db.
    > >
    > > 2) I want to display the image within a web page, so I would want to

    pull
    > > the image out of the db, place it on my web server in a certain

    location,
    > > and then reference the file in the HTML. How do I do that?
    > >
    > > Thanks in advance for any help you can provide.
    > >
    > > --Mike
    > >
    > >

    >
    >
     
    Michael Walton, Dec 30, 2003
    #8
  9. Michael Walton

    Brynn Guest

    So your content guy has his web server, and you have your DB server
    ... right? That's gotta suck ... can he create a virtual folder for
    the website ... a folder that is on your server?

    On Tue, 30 Dec 2003 12:20:18 -0500, "Michael Walton"
    <> wrote:

    >Right - I totally understand. However, when that image isn't there, because
    >dumb-idiot content developer has moved it or deleted it, how efficient is
    >the empty image with the red x in it?? I totally understand what I am
    >asking, and unless you have a better way to control the images on the
    >server, I have to use the DB to do it. This will take the control away from
    >the content developer and put it back into my hands. Trust me....the way
    >you are telling to do it is the way I've done it for 10 years, but its not
    >working in this environment, because of the morons I'm dealing with.
    >
    >--Mike
    >
    >"Foo Man Chew" <> wrote in message
    >news:...
    >> > 2) I want to display the image within a web page, so I would want to

    >pull
    >> > the image out of the db, place it on my web server in a certain

    >location,
    >> > and then reference the file in the HTML.

    >>
    >> Read that sentence a couple of times, and think about how efficient that

    >is
    >> compared to <img src=/images/uploadedImage.jpg>
    >>
    >>

    >
    >
     
    Brynn, Jan 3, 2004
    #9
    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. Guest
    Replies:
    3
    Views:
    1,578
    bruce barker
    Nov 22, 2003
  2. Manish Naik
    Replies:
    2
    Views:
    6,715
    Manish Naik
    Jun 30, 2004
  3. Luis Esteban Valencia

    How to retrieve images from sql server?

    Luis Esteban Valencia, Oct 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    405
    BluDog
    Oct 22, 2004
  4. sarathy
    Replies:
    2
    Views:
    666
    sarathy
    Jul 17, 2006
  5. Jonathan Wood
    Replies:
    1
    Views:
    511
    Jonathan Wood
    Jun 2, 2008
Loading...

Share This Page