Saving and Retrieving Images From SQL Server Using DAAB and ADO.NET 2.0
- 0
- Add a Comment
Does saving images to a SQL server having you spinning in circles? Then perhaps David Hayden can shed some light on the matter below…
An interesting question in my Inbox about how to save and retrieve images using the Enterprise Library 2.0 Data Access Application Block ( DAAB ) and SQL Server.
I am not sure using DAAB changes the code all that much, since most of the code is really converting images to byte arrays and vice versa.
I, honestly, don’t store images in SQL Server, because if you serve up those images a lot I think you may experience a performance hit in your applications. My gut says that streaming large binary images across a tier ( database to webserver for example ) quite often will make your application less scalable and just plain slow. However, if those images are small and/or you incorporate the right amount of caching, you certainly can get away with it. And, of course, if the application is small, you can do just about anything :)
I did some searching and I couldn’t find a good example on saving images to SQL Server, so here is my take on a good way to do it. This example is using SQL Server 2000 and the Image Data Type. In SQL Server 2005 you would use the VARBINARY(MAX) Data Type as the Image Data Type is no longer preferred in SQL Server 2005….. Source: davidhayden.com
Tags: sql server, .net 2.0, image data type
