What is the best way to use classic ASP and MySQL Blobs

Posted on 2009-12-20
Last Modified: 2012-05-08
Im trying to write pages for an admin back end for an image gallery in Classic ASP. Does anyone know of tutrials or modukles out there to help.
Question by:bobbby_
    LVL 23

    Expert Comment

    My suggestion would be to never store blobs in a database.
    1. They are very hard to maintain and a pain to extract
    2.  Your database backups will be emense!
    3.  The size of your database and performance may go down if it gets loaded. This was my experience anyway
    I would suggest storing the location of the file in the database and have the actual file in an organised file system within your web server.
    You can find Image upload scripts everywhere, just save the file to the file system, then save the record in your database and you are set.
    You will be better off writing it yourself because it if ever breaks you have a better chance of actually fixing it :)
    If you still want help with the blobs i will

    Author Comment

    Hi apresto

    I'm storing the locatoon at the moment. The database is on a different machine sos maybe thje performance is not an issue. The galleries will only be a few images and I was wondering if it would be an easier experience for the client if the image went straight into the database with no worries about folders etc. The hoster is jumpy about stting read write permissions on any folder because of hacking (paranoid maybe)

    It would be nice to be able to this anyway. I'm busy swapping to .NET but my boss does not give this a prority. yet|

    LVL 12

    Expert Comment

    The code below shows how to add the image data into the database, assuming its call binaryimagedata - you will need to work the code out to get the image data based on how you do the upload.

    I do store "thumbnails" in a database and it works very nicely.  However I also use ASPJPEG to resize every image that is uploaded before adding it to the database which ensures that amount of data for each image is relatively small.

    If you need help getting the image back, or with the upload bit then let me know - I will also need to know if what upload component you are using if you want me to help develop code.
    Set Conn = Server.CreateObject("ADODB.Connection")
    Set RS = Server.CreateObject("ADODB.Recordset")  = ' ADD YOU DATABASE CONNECTION DATA
    RS.Open "YOURTABLE", Conn, 1, 3

    Open in new window


    Author Comment

    Hi R_Harrison

    Thanks for this. Yes I would like help getting the image back. I need to "upload" and store then, retrieve and display. I use PureASP Upload 3 with the "advanced multiupload" add on from DMXZone, but I'm not so sure that batch uploading them is OK in this case. Is it this simple? what was all that stuff about opening streams I read about? :o)

    Merry Xmas

    Bob Scott
    LVL 12

    Accepted Solution

    Sorry for the delay was away for Xmas!   I'm not familiar with PureASP Upload 3 and haven't found a helpful manual.   Most upload components will provided you with access to the raw binary data from the file that was uploaded - usually something like (this is for the a component called "ABCUpload")...

    Set theForm = Server.CreateObject("ABCUpload4.XForm")
    Set theField = theForm("filefield")(1)

    Then on line 6 of my code you can use the value:  theField.Data  as this holds the raw binary data from the file e.g  RS("FieldNameOfYourBlob").Value=theField.Data

    I hope this is of some help - if you are still stuck it might be worth posting the question again but mentioning that you are using "PureASP Upload 3" so that an expert familiar with this component will take it up.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
    Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now