N-tiers development method (ASP/ASP. NET, VB6/VB. NET call uses the COM + component)

Source: Internet
Author: User

Generation: N-tiers development mode (Modification and modification of COM + components)

After the component security is complete, the next task is to call the components we have installed. The names of components we have set are as follows:

Package: kdmo1000
Project: pdmomenu
Class:
Cdmomenu1 (no transaction)
Cdmomenu2 (with Transaction)
One function in the false cdmomenu1 is getnodename. The number of nodeids (integer) is imported into the role, and the return value is nodename (string)
Getnodename (byval nodeid as integer) as string

 

Late binding:

The usage method I mentioned here is to useLate binding. That is to say, the component will not be registered to yourASP. NETOr yourVB. NETWhen the system is runningServerSet this objectBind. The disadvantage is that you cannotOBJ.You can select the attribute method in the pop-up component. You must use the attribute method by yourself.KeyinGo in. However, when your components have been changedReferenceYour components.ASP,ASP. NET,VB,VB. NETYou call components in the same way.

Call components:

Call components are as follows:

ASP:SetOBJ= Createobject("Pdmomenu. cdmomenu1")
Nodeid= 2 
Nodename=OBJ. getnodename (nodeid)

VB: Dim OBJ As   Object  
Set OBJ =   Createobject ( " Pdmomenu. cdmomenu1 " )
Dim Nodeid As   Integer  
Nodeid =   2  
Dim Nodename As   String  
Nodename = OBJ. getnodename (nodeid)

ASP. NET/VB. NET Dim Nodeid As   Integer   =   2  
Dim OBJ As   Object   =   Createobject ( " Pdmomenu. cdmomenu1 " )
Try  
Dim Nodename As   String   = OBJ. getnodename (nodeid)
Catch Ex As Exception
Me . Lblerrmsg. Text = Ex. Message. tostring ()
Finally  
' Resource Recovery
OBJ. Dispose ()
OBJ =   Nothing  
End   Try

 

NetCall components must be released by themselves:

From the aboveProgramCode, You can find that the call component process is almost the same, using. NetAt the time of writing, the call method can be simpler.

After the component is called for execution, you can find Package The components in are called and switched. If you use ASP, VB6 Call the component, you can find that when the call is complete, the component turns to stop, and the component number in the call is also reset to zero. However . Net Call components, if not written 【 Try... catch... finally... end tryAnd 【 OBJ. Dispose () ],【 OBJ = nothing ] Put in Finally The components in [Component Service] will not stop. This is because ASP, VB6 After the program is executed 【Resource RecyclingBut in . Net Medium 【Resource Recycling] Must be manually executed by the program designer. Otherwise, it must be started when the system resources are insufficient. GC Can be recycled.

Related Article

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.