Home > Article > Backend Development > Serving images to web browsers with SQL Server_PHP Tutorial
Microsoft SQL Server database server can save images and large amounts of text in SQL databases. The data types used for pictures and text are image picture type and text text type respectively. If you use VB or VC to develop a front-end application and run it on a Windows operating system, you can easily extract image data from the SQL database, put it into a file, and display it on the screen. However, if you want to get pictures from SQL Server and display them in a Web browser, it is not so easy. Although Microsoft SQL Server 6.5 provides Web Assistant and stored procedures sp_makewebtask and sp_runwebtask, which can convert data in the SQL database into HTML files, we have a better solution. One problem with using the Web Assistant is that it does not accept fields of image data type. On the other hand, the stored procedure sp_makewebtask has too many parameters, making it difficult to use and difficult to customize the Web page.
We provide a solution here to load images from SQL data to a web browser. This solution is better than sp_makewebtask. We developed a Web project using an ActiveX dynamic link library and ASP pages. The dynamic link library is responsible for opening the connection to the SQL database where the images are saved, extracting the images from the database and saving them in temporary files. ASP communicates with the dynamic link library to obtain the location of the temporary image file. This way, when a visitor clicks on the Web site, the image is downloaded to his browser. In this article, we will introduce the steps to set up a SQL database. Then, we will also introduce how to use VB5 and Active Data Objects ADO 1.5 to build an ActiveX dynamic link library. Finally, we'll discuss the process of setting up an ASP Web project, connecting to a SQL database, and writing ASP files.