Archive for 21st August 2008

Displaying An Image Stored In A SQL Server Database On An ASP.NET Page Using VB.NET

Recently asked on Yahoo! Answers:

How do I read and write binary image data from SQL server?
I’m making a website where visitors can upload their images, I’ve done the uploading code and it (probably) works fine because I can see the data is recorded on the database.

The problem is when I want to test it (display the image on the website) theoretically I have to read the data from the SQL server and write it to the web. I’ve done several ways and tests but all of them failed to display the image.

Anybody knows how to do this? I’m using visual web developer 2008 and VB.NET as programming language

Note: no “wizards” please, I want it to be implemented using fully coded like I did with the uploading code

There are other examples on the Web on how to do this, but most are either written in C#, or are very specific to a given set of circumstances, so I thought I would explore this subject for Visual Basic .NET, and in the process try to address a few different ways to display an image.

The executive summary: Displaying an image that’s stored in a database requires you to make a “helper page.” And that’s what we’re about to make.

Continue reading ‘Displaying An Image Stored In A SQL Server Database On An ASP.NET Page Using VB.NET’ »