In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to develop IIS applications by VB". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
I. Overview
As you know, IIS (Internet Information Server) applications are VB applications that use HTML and compiled VB code in dynamic, browser-based applications. The IIS application resides on the Web server, accepts requests from the browser, runs the code associated with the request, and returns the response to the browser. IIS applications can use VB code to perform functions previously done with scripts, CGI processing, and other methods. IIS applications can run on any browser, so it is easy to get a wide range of applications. To the user, an IIS application seems to consist of a series of HTML pages. For developers, an IIS application is made up of special types of objects called Webclass. Webclass contains a series of resources called Webitem. As the core of the application, Webclass processes data from browsers and sends information to users. Webitem is the HTML page and other data that Webclass sends to the browser in response to a request.
Second, the VB development process of IIS application
The development process of an IIS application is roughly divided into five steps. We combine an official document data retrieval program to illustrate.
1. Set up the IIS application project
When building an IIS application, you should select the IIS application type project. The IIS application project is an ActiveXDLL project type that automatically includes an ActiveX designer. This designer, called Webclass, serves as the basis for creating applications. A Webclass designer corresponds to a Webclass, but it can contain multiple HTML templates and Webitem. If you want to include multiple Webclass in your application, you must insert another designer in your project. In most cases, you have to write code to tell Webclass what to do when the application starts * times, using the Start event to do it. The Start event occurs when the user visits your application * times. Use the Start event code to roam to * Webitem in the application.
For example, let's build an IIS application named SearchData and write the Start event code for Webclass as follows:
Private Sub Webclass_Start () Set NextItem=SearchTpl End sub
2. Add HTML template to Webclass
Adding a HTML template to the IIS application enables Webclass to send a HTML page to the browser in response to a user's request. When you add a template to Webclass, select a HTML page associated with it. A Webclass can contain multiple template Webitem, but each template Webitem can only represent one HTML page. You must add a template for each HTML page. After inserting a HTML page file, you can use the HTML editor to make changes to the content and layout of the page. For example, we add a template called SearchTpl, Webitem, which is associated with a SearchCondition page, and write a Respond event to write the contents of this HTML page to the browser.
Private Sub SearchTpl_Respond () SearchTpl.Write Template End Sub
The SearchCondition page associated with the SearchTpl template allows the user to enter search criteria. Its contents are as follows:
< HTML > < head > < metahttp-equiv= "Content-Type" content= "text/HTML;charset=gb_2312-80" > < title > search conditions < / title > < / head > < body bgcolor= "# FFFFFF" > < form action= "SearchData_Webclass.asp? WCI=SearchResult "method=" POST "> < p > start date < inputType=" text "size=" 10 "name=" date1 "> < / p > end date < inputType=" text "size=" 10 "name=" date2 "> < / p > < p > File size < inputType=" text "size=" 50 "name=" code "> < / p > < p > text title < inputType=" text "size=" 50 "name=" title "> < / p > < inputType=" submit "name=" submit "value=" OK "> < inputType=" reset "name=" clear "value=" clear < / p > < / form > < / body > < / HTML >
3. Add custom Webitem to Webclass
Custom Webitem allows you to dynamically send responses to browsers through VB code. A custom Webitem is usually a set of process code. Most of the processing in IIS applications occurs during custom Webitem events. The IIS application receives the request from the HTML page, matches the event of the Webitem, and runs the corresponding event procedure code. For example, we add a custom Webitem named SearchResult. It uses the Request object to get the query conditions entered by the user in the SearchCondition page form, and then establishes a connection to the ADO document database, creates a recordset and retrieves the information that meets the criteria.
Private Sub SearchResult_Respond ()
'declare variables to get information about the form
Private sDate1 as String
Private sDate2 as String
Private sTitle as String
Private sCode as String
'get the form parameters and assign them to the variable
SDate1=Request.Form ("date1")
SDate2=Request.Form ("date2")
STitle=Request.Form ("title")
SCode=Request.Form ("code")
'declare object variables for database connections and recordsets
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim QueryStr As String'
'form a SQL data query string
QueryStr= "select form document where" & "date > =" & "#" & sDate1 & "#" & "and" & "date <
= "&" # "& sDate2 &" # "&" and "&" File title like "&" * "&" * "& sTitle &" * "&" * "&
"and" & "File name like" & "*" & "& sCode&" * "&"
'establish a database connection
Cn.ConnectionString= "DSN=doc;UID=sa
PWD=sa;DATABASE=document "
Cn.Open
'create a recordset
Open QueryStr,cn,adOpenStatic,adlockReadonly
'write the result information into a table one by one
With Response
.write "< HTML >"
.write "< BODY >"
.write "< TABLE BORDER CELLSPACING=1 CELLPADDING=7 >"
Do While rs.EOF=False
.write "< TR > < TD >"
.write rs ("file title")
.write "< / TD > < TD >"
.write rs ("file size")
.write "< / TD > < TD >"
.write rs ("date")
.write "< / TD > < TR >"
.write rs ("unit of responsibility")
.write "< / TD > < TR >"
.Write rs ("subject words")
.write "< / TD > < TR >"
Rs.MoveNext
Loop
.write "< / TABLE >"
.write "< / BODY >"
.write "< / HTML >"
End With'
'close recordset and database connections
Rs.Close
Cn.Close
End Sub
4. Debug IIS applications
The way to debug an IIS application is the same as debugging other VB applications by entering run mode. VB creates a virtual directory for the IIS application and uses a browser to open the appropriate .asp file to start Webclass. When debugging, you can use all the tools of VB to debug your project. Such as setting breakpoints, viewing variables, debugging statements, and so on.
5. Deploy IIS applications
You can use the VB Packaging and deployment wizard to wrap and deploy your IIS application. The package and deployment wizard wraps the project's .DLL file and all related files into a "zip package" or .cab file. You can then deploy the archive file and related files to a Web server.
This is the end of "how VB develops IIS applications". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.