15. Common ASP ActiveX Components

xiaoxiao2021-03-06  37

When you write a server-side application with ASP, you must rely on the ability of the ActiveX component to power the web application, such as: You need to connect the database, perform online operation on the database, etc., follow the article, after the article, this article Will then give you some other commonly used ASP ActiveX components.

There are still many friends in recent recently to ask me, whether the ASP can only run on Microsoft IIS, can you operate on a non-NT platform? I have already answered many times this question: I just heard that some kind of software that can support, but never seen it. But some enthusiastic friends still have a tireless to ask, so I am visiting the ASP-related sites under the prevalence of friends, and the ASP is indeed on other non-NT platforms, so in this The beginning of the article, I briefly introduced the friends of the letter to how to use ASP on a non-NT platform.

To develop and run the ASP application on a non-NT platform, we can rely on a third-party software called Instant ASP. Its advertising slogan is very attractive "ASP Anytime, Anywhere", I think all ASP developers look So whisper is inexpensive. This set of software developed by Halcyon Software allows you to run it on any action platform without repeated development of the original ASP application! This is not a large number of development time, and the ASP has truly become a cross-platform Internet, Intranet, or Extranet application. Instant ASP itself is actually a Java-based application, so you can run web-based ASP applications on any platform, the following table lists the operating platforms supported by Instant ASP.

What is more surprising is that INSTANT ASP not only provides ASP's operating environment, but it is more powerful and practical than the current ASP app on the current market. It combines ActiveX components and Enterprise Java Beans or CORBA-Compliant Objects. Get up, so that the ASP has a broader application. It also provides a powerful feature that connects to various databases through the ADO interface and generating dynamic pages. For developers, you can use your programming language or tools such as: Visual Basic, JScript, VBScript, C , Java, HTML, Delphi, MS Visual InterDev, etc. Regarding the specific installation and operation of Instant ASP, I will not be unfold here. Interested friends can go to its site to see HalcyonSoft.com, you can also download a trial version for free.

Following the authors introduced you to the use of the AD Rotator component, we will then look at some other ASP common components.

First, Database Access Components

The most common and most practical tasks we use to use web applications on the web server are to access the server side database. The ASP built-in Database Access component allows us to easily access information stored in a server-side database or other formalized data structure through ActiveX Data Objects (ADO). ADO is the most effective and simple and straightforward method for operating the database supported by Microsoft. It is a powerful data access programming mode that makes most data source programmable properties to be extended to your ACTIVE. On the Server page. You can use ADO to write compact scripts to connect to Open Database Connectivity (ODBC) compatible databases and OLE DB-compatible data sources, so ASP programmers can access any database compatible with ODBC, including MS SQL Server, Access, Oracle, etc. If you are a script writing personnel with a certain understanding of the database connection, you will find that the ADO command statement is not complicated and easy to master. Similarly, if you are an experienced database programmer, you will correctly understand the advanced language-independent and query processing features of ADO. Friends who are familiar with VB database programming will find that ADO and RDO (Remote Data Objects) have some similar place. But it is said that ADO's access is faster, and memory needs to be smaller. Let's briefly introduce the step of connecting the ASP's Database Access component through the ADO and operating the web database.

Step 1: Specify the database you want to connect, there are two ways of DSN and DSN-LESS.

DSN (Data Source Name Data Source Name): Create a system data source name, the method is as follows:

1. Click Start, select the Control Panel.

2, double-click the icon "32-bit ODBC", will pop up a dialog, select "System DSN"

3. Click Add to add a DSN entry, select "Microsoft Access Drive" and confirm.

4. Enter the DSN you want to specify in the "Data Source Name" field, then click "Select" to select the data inventory location, you can press "Browse" to select.

5. After the above step is completed, specify DSN in the ASP program, as follows:

<% connStr = "DSN"%>

DSN-LESS: Another way to establish a DSN by specifying the location of the database file directly in the ASP file without having to establish a DSN. Since many companies do not have their own web servers, their website is often stored on the far-end virtual server, so it is more troublesome to establish and modify the settings of the DSN. The use of the DSN-LESS method directly specifies that the remote database is just solved in the location, the method is as follows:

<%

Connstr = "dbq =" server.mappath ("Database / Source.mdb") "; defaultdir =;

Driver = {Microsoft Access Driver (* .mdb)}; driverid = 25; FIL = MS Access;

ImplicitCommitsync = YES; maxbuffersize = 512; maxscanrows = 8;

Pagetimeout = 5; saFetransactions = 0; threads = 3; usercommitsync = yes; "

%>

After you specify the database you want to connect, you can connect and open the database by the following method:

<%

Set conn = server.createObject ("AdoDb.Connection" Conn.open Constr%>

Step 2: Specify the SQL instruction you want to execute, you can use the Recordset.

When you connect the database, you can operate the database, such as query, deletion, update, etc., these operations are done by SQL instructions, as follows, in the database table DateBase, query all names "A" records:

<%

SQL = "Select * from datebase where name like 'a %%'"

SET RS = Conn.execute (SQL)

%>

Although the Connection object simplifies the connection database and query tasks, there is still a lot of shortcomings in the Connection object. Specifically, the Connection object that retrieves and displays database information cannot be used to create scripts, and you must know the changes you want to make for the database before you can use the query to make changes. For retrieval data, check results, change the database, ADO provides the Recordset object. As its name, the RecordSet object has many features you can use, retrieved and display a set of database lines according to your query restriction, and display a set of database lines. The Recordset object holds the location of the record returned by the query, allowing you to step by step by step. You can scroll and update records according to the pointer type property settings of the Recordset object. The database pointer allows you to locate a specific item in a set of records. The pointer is also used to retrieve and check the record, and then perform the operation on the basis of these records. Recordset objects have some properties that can be used to accurately control the behavior of pointers, enhance your ability to check and update results.

The use of Recordset is as follows:

SET RS = Server.createObject ("AdoDb.Recordset")

RS.Open SQL Directive, CONN, 1, 1 'Read

or

RS.Open SQL instruction, CONN, 1, 3 'new, modified, or delete

Step 3: Use the RecordSet attributes and methods and display the results of the execution.

With the above instruction, we created a cursor "RS" containing the data, and the trigger is a similar record and field of the similar records and fields stored in the active memory. When you create a cursor via the RecordSet component, it is from the data The provider gets a data set, and uses it to enrich the cursor, we can imagine the recordset generated by ADO is a record of the spreadsheet, it has a line of records, there is a line of it is its current row, and Recordset The field is represented by the Field collection of Recordset. Some of the properties and methods of the created Recordset object (cursor) are listed below:

Rs.fields.count: The total number of fields of the Recordset object.

RS (i) .name: The name of the i-th field, i is calculated from 0 to rs.fields.count-1.

RS (i): Read the data of the i-th field, i is calculated from 0 to rs .fields.count-1.

RS ("Field Name": Read the data of the specified field.

Rs.Recordcount: The total number of data records in the cursor.

rs.eof: Whether it is pointed to the last record.

Rs.Movenext: Move the indicator to the next record.

Rs.MovePrev: Move the indicator to the previous record.

Rs.MoveFirst: Move the indicator to the first record.

Rs.MoveLast: Move the indicator to the last record.

Rs.close: Turn off the Recordset object About other introductions of ADO, the author will give you a detailed explanation in the future.

Second, Content Linking Components

If your site has a series of interrelated pages, the Content Linking component will be very suitable for your needs, it doesn't make you create a directory table in these pages, and you can build dynamic connections in them, and automatically generate and Update the directory table and the navigation link for the previous and subsequent web page. This is a very ideal choice for listing online newspapers, electronic reading websites, and forum mail.

Content Linking Components Create a NEXTLINK object for the URL list. To use the Content Linking component, you must need to create the Content Linking List file first. The Content Linking component is using this file to get information about all pages that we want to link. In fact, the file is a plain text file, its contents are as follows:

Page1.htm One

Page2.htm Two

Page3.htm Three

Page4.htm Four

Page5.htm Five

Page6.htm Six

Each line of this text file has the following form:

URL Description Comment

Where the URL is a page-related hyperlink address, Description provides text information that can be used by the chain, and Comment contains annotation information that is not interpreted by the Content Linking component, its role as comments in the program. Description and Comment parameters are optional.

Let's take a look at how to specifically use the Content Linking component:

Network Electronics Reading Treasure </ Title></p> <p></ hEAD></p> <p><body></p> <p><p> network electronic reading navigation</p> <p><%</p> <p>Set link = server.createObject ("mswc.nextlink")</p> <p>Count = line.getlistcount ("NextLink.txt")</p> <p>DIM I</p> <p>For i = 1 to count</p> <p>%></p> <p><ul> <li> <a href = "<% = link.getnthurl (" NextLink.txt ", i)%>>>></p> <p><% = Link.getnthdescription ("NextLink.txt", i)%> </ a></p> <p><% Next%></p> <p></ body></p> <p></ html></p> <p>In the above code, we first use the getListCount method to determine how many items in the file nextLink.txt, then use the loop statement, and use getnthurl, the getnthdescription method will be stored in the nextLink.txt file in the nextLink.txt file and display to the customer. End browser.</p> <p>The number of items in the Content Linking component all available methods of use GetListCount (File), the number of items in the list files are listed.</p> <p>GetNextURL (file) Gets the URL of the next page listed in the Content Link list file.</p> <p>GetPREVIOSDESCRIPTION (File) Gets the description line of the previous page listed in the content link list file.</p> <p>GetListIndex (file) Gets the index of the current page in the content link list file. GetNTHDescription (file, index) Gets the description of the Nth page listed in the Content Link List File.</p> <p>GetPREVIOSUR (File) Gets the URL of the previous page listed in the content link list file.</p> <p>GetNextDescription (file) Gets the description of the next page listed in the content link list file.</p> <p>GetNTHURL (File, INDEX) Gets the description of the Nth page listed in the content link list file.</p> <p>After we created the total navigation page of the website, we certainly wish to add a "Previous", "Next" navigation hyperbank, let's take a look at how to implement the navigation hyperlink.</p> <p>Since your website may contain thousands or more pages, we cannot write ASP code that implements navigation hyperlinks in each page. Therefore, we must take advantage of the server-side of the server to be in the first few, so avoid a lot of repetitive work, please see the case:</p> <p><! - # include file = "Nextprev.inc" -></p> <p>Just put this code in each page. The contents of the nextPrev.inc file are as follows:</p> <p><%</p> <p>Set link = server.createObject ("mswc.nextlink")</p> <p>Count = line.getlistcount ("NextLink.txt")</p> <p>Current = line.getlistIndex ("NextLink.txt")</p> <p>IF current> 1 THEN</p> <p>%></p> <p><a href = "<% = link.getpreviousurl (" NextLink.txt ")%>"> Previous </ a></p> <p><%</p> <p>END IF</p> <p>IF current <count dam</p> <p>%></p> <p><a href = "<% = link.getnextURL (" NextLink.txt ")%>"> Next </ a></p> <p><% End if%></p> <p>Today's study is over, here I want to thank all my friends who care about my article again, your letter gives me a lot of encouragement, but please call me "teacher", in fact, I also Like you are constantly learning and exploration, there are problems we can discuss together, there are still many shortcomings or vulnerabilities in my article, and I hope that everyone can find it in time. Since the ASP has been widely used in the domestic website, we should write some ASP applications as the sister articles of this article in China, as required. Provide some truly practical things, please pay attention.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-58008.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="58008" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.045</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = '3CPvkAfugTjVFN_2BVb3Q5bsh5WNQ6UpJhNKG7rLavvto_2BkN4y0APXj71XecbBqeuIsHziApbGi2nOXcPfFaD6mw_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>