Set up a Web project and set up a database connection
After registering the Imageloader dynamic link library, we can build the Web project. We use Microsoft Visual InterDev 1.0 to build an ASP page to
and a data connection to the Microsoft SQL Server database.
First, open Microsoft Visual InterDev. In the File menu, select the New menu item. In the dialog box that appears, select the Web project to
Guide, enter imageload in the Project Name field. Click OK to complete the next two steps to end the wizard.
As you can see, Visual InterDev automatically generates a file in the workspace (Workspace) window, called Global.asa. The first time the user
When you view a page in a Web application, the file is automatically generated. To connect to a database in SQL Server, select an item | Add Item (Project |
Add to Project), and then select the data Connection (Connection). Here, select the Data Source dialog box to appear, we must define a data source name
Called (DSN).
Click the New button, select SQL Server in the list of available data drivers listed, and then click Next. Next, in the input box
Enter Grocevb as DSN. The next few steps are easy to complete and no longer detailed.
Below, the SQL Server logon dialog box appears. Enter the server name, login ID, and password, and click the option button. From the available data listed
Library list, select Grocevb and click OK. After you have completed all of the above steps, you are returned to the Select Data Source dialog box. Here, from DSN
List click the file name Grocevb.dsn and complete the next few steps to end the operation.
Now, you can double-click Global.asa to see the code generated in this file in the above steps. The code defines some of the changes necessary to connect to the SQL Server database
Amount
In order to initialize the class Clsimageloader, two lines of code must be placed at the beginning of the global.asp. We have listed the code in Global.asa in List C. Note
Meaning Clsimageloader is a session-wide object.
Sub Session_OnEnd
Set Objimageloader = Nothing
End Sub
</SCRIPT>
Building an ASP page
In order to connect to the database and communicate with Imageloader this dynamic link library, we built an ASP file in the Web project. method is in the file
menu, select the New menu item, select the ASP page icon in the File tab, and enter the file name in the input box. We put this page
Named Default.asp. The code contained in Default.asp is shown in Listing D.
Note: The Createtempimagefile method defined in the class Imageloader and the ImageFile property (read-only) require a picture ID as an argument. In this example
, the picture ID is the primary key for the table products (prod_id). Therefore, the value of the prod_id must be passed to the dynamic link library.
Summarize
In this article, we demonstrate a method that uses the ActiveX dynamic link library and ASP to mount pictures from Microsoft SQL Server servers to web browsing
Manager It has been shown that this approach has an advantage in the flexibility of rapid development, ease of use, and customization of Web pages. The dynamic link library is used to connect to the database, mentioning
Take picture data, put the picture data into the file. The ASP page is responsible for communicating with the SQL database and the dynamic link library. We've covered setting up SQL databases and web
The operation process of the project.
Although the dynamic link library and database functionality in this article has been simplified, the steps described here are valid for any other powerful and complex Web project
Of
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.