These days some people asked about the problem of compiling a. dll, here posted an article, Hey!

Source: Internet
Author: User
Tags functions iis table name visual studio
The problem ActiveX DLL can be used to protect some parts of the code, because as a developer we know that source code control is a difficult and trivial process when working with an ASP. An ActiveX DLL is a compiled code that cannot be modified without the source code in the engineering file. This gives developers a number of possibilities: developing programs that automate public programs and distributing them as shareware, distributing at least some source-code-protected ASP applications, and constantly developing their own ASP program directives to improve the performance of the ASP in a full range of multi-functional results.

The first ActiveX DLL file that you install will register and install the Visual Basic 6 Run-time file, which allows you to run compiled code. Note, however, that this also requires that the server be restarted. When an existing DLL is installed and used, if you want to upgrade it, the server will give an error message indicating that the file is being used by another procedure. To correct this problem, restart the server before you can complete the upgrade of the DLL. Remember to use a test environment in development.

While this example is very simple, it can be easily implemented with an ASP file, but when you develop an ActiveX DLL, you can use the full set of basic instructions for Visual basic, System shell directives, and all the operations that the console can do. So it allows the full automatic control of online websites and the internal Internet. This expands the performance of an ActiveX DLL that was originally implemented with ASP included files.

Storing the value of a query key in a database field populated with a combo box, improving the integrity of the data, and easily cascading updates across the database are common operations. For example, there is now a misspelled text description that can be modified in the look-up table, and all relevant items that have selected this description are automatically modified because we have stored the numbers associated with this description. The combo box is based on the contents of the query table, which links the value of the query keyword to its description, and if the system uses many queries, the code that produces the combo box becomes very repetitive. This article uses an ActiveX DLL to simplify the process of creating an HTML combo box, populating it with the contents of a database query table. The table name in the example is lookup_table, which has the following fields:

Lookup_key: Values stored in the database
Lookup_field: Classifying query elements
Lookup_description: The description displayed in the combo box
To create an ActiveX DLL, follow these steps:

Start a new Visual Basic engineering file;
Select the ActiveX DLL as the project file type;
In the Properties window, name class modules and engineering files. Name the project file Keiths_lookup and name the module lookup. These names are used when ASP references DLL functions. Later in ASP code, a server object named Keiths_lookup.lookup will be referenced.
Save the project files and modules with the same name, where the project file extension is. vbp, and the class module has the. cls extension. In this example, the name of the project file is Keiths_lookup, and the module's name is lookup.
In the Project menu, select References. This is the other application object that you can use. In this case, check the Microsoft ActiveX Data Objects 2.0 library and the Microsoft ActiveX Data Objects Recordset 2.0 library.
Create a dataset named Sumnet in the IIS server database that contains the query table. This database does not have a username and password.

You can now type the following code:


Public Function Html_combo (ComboName As String, Lookup_field as String) as String

Dim outstring as String
Dim Conn as ADODB. Connection
Dim rst as ADODB. Recordset
Dim SqlString as String

Set conn = CreateObject ("ADODB. Connection ")
Set rst = CreateObject ("ADODB.") Recordset ")

SqlString = "SELECT [Lookup_description],[lookup_key] From
[Lookup_table] WHERE [Lookup_field] = ' "& Lookup_field &" "

Conn. Open "dsn=sumnet; uid=; Pwd=.; "
Rst. Open SqlString, Conn, 3, 3
If not rst. EOF Then
Rst. MoveFirst
outstring = "< Select name= '" & ComboName & ">"
Do as not rst. Eof
outstring = outstring & "< Option value= '" &
Rst. Fields ("Lookup_key") & "' >" & _
Rst. Fields ("Lookup_description") & "</option >"
Rst. MoveNext
Loop
End If

outstring = outstring & "</select >"
Html_combo = outstring
Rst. Close
Conn. Close

End Function

Then, save the engineering files and class modules.

The steps to compile the project file are as follows:

Start the package deployment Wizard in the Visual Studio 6.0 tool;
Select the ActiveX engineering file you just created;
Click Package;
Select the package script name or use the default value;
Select Standard Setup;
Select a folder where the installation files are placed;
Select a single cab;
Click Next to use the other default options;
Run Setup on the IIS server.

You can now use the DLL in ASP code because it is already registered in the system database. The following ASP code will use the created LL internal function. It will produce three combo boxes, one filled with state, one filled with position and the other in age group. The first argument becomes the name of the object on the Web page, and the second parameter is the value used to populate the query field in the combo box.


<%@ language= "VBSCRIPT"% >
<%
Set look = Server.CreateObject ("Keiths_lookup.lookup")
% >

< HTML >< body >

<%=look.html_combo ("state", "States")% >
<%=look.html_combo ("Position", "positions")% >
<%=look.html_combo ("Age_group", "age_groups")% >

</body >

This example is very simple. By using more parameters, such as table names, domain names, and so on, you can create many portable functions that can be used in a variety of applications that you encounter in your work.

Because the code is run horizontally at the server end, the client does not need to install anything. This is just a small example of the functionality that an ActiveX DLL can achieve. With just a little effort, you can get a versatile application that is unique among network users.



Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.