How to store Images (.jpg, .bmp) in DB?

  • Since I have to develop a solution for catalog printing using Seagate Crystal Report, and Crystal Reports support only if images are stored within the database.

    Can anyone help me to advise a simple and straight method within SQL Server to store and retrieve images by T-SQL?

  • They are stored as binary and retrieved with a select statement, like any other field.

    The trick is on the front end. It has to be able to read the values and decode them as binary.

    I know there was a bug in ADO for awhile that your text/image data needed to be the last fields in your select statement. Are you using ADO?

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

  • Use the OS command TEXTCOPY to get the graphics into the table. Crystal should be able to read them as long as they are bitmaps, jpegs or gifs.

    I wrote a simple stored proc that calls xp_cmdshell to run text copy, and then called this stored proc from VB to automate it. If I find it I`ll send it along, otherwise textcopy will do the job!

    Andy.

  • Did you find an advantage to textcopy over using an ADO stream?

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • I, too, need to be able to store graphics (tiffs in this case). However, I'm much more the novice in SQL Server 2000 workings. Could someone tell me, step by step, how I can store and retrieve graphics through a SQL Server table?

  • Have a look at this FileUploader Library for ASP

    http://www.asp101.com/articles/jacob/scriptupload.asp

    I used this to grab jpegs to display on ASP pages, but it could pick-up files of any type, and should be easy to convert to VB/VBA.

  • I'm not sure if I undestood correctly the problem - do you need actually to store image files in the database? or you need to be able just to display them by calling their path?

    The common practice is to store paths like : images\pic_1.jpg

  • To display in report, Crystal Reports needs images stored in the DB . Does anybody has a solution to store images in DB so that crystal report can access images and display in report.??

  • Storing BLOBs in SQL Server, or an RDBMS is not really fun. The SQL Server 2000 Resource Kit has an example (Bii.exe) that is useful for an example. As well there is an interesting article at:

    http://www.123aspx.com/redir.aspx?res=28951

    Microsoft's TerraServer is an excellent example of SQL's BLOB storing capabilities

  • Check this on support.microsoft.com

    Microsoft Knowledge Base Article - Q258038

    HOWTO: Access and Modify SQL Server BLOB Data by Using the ADO Stream Object

  • There is always a way to avoid storing external files in a data base table. I would avoid doing this at all costs.

    If you insist, use a varbinary field if the files are small, or an IMAGE field. Again, i would avoid storing this objects in your data base. Instead store a pointer to where they are stored on your file system or web server and use them from there instead. You will be MUCH happier.

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply