Application of Data stereotypes in ASP

Source: Internet
Author: User

Data stereotypes are the process of defining a custom record set. We can consider a qualitative record set as a hierarchical record set. There are three types of hierarchical record sets:

Link level, parameterized level, and group level.

I think the biggest advantage of this technology is that there is no data redundancy, the interface display is clear and simple, and multi-layer data operations are more convenient.

To apply this technology, you must set the provider in the data-driven connection string to msdatashape.

The specific application requires the shape Command, which has two different shape statements:

1. Shape {sql1} append ({sql2} ?? Relate A to B)

The method of work is: first query sql1, then query sql2 Based on the condition specified by relate A to B, and then add a field after the sql1 search result, the records set used to save the corresponding sql2 query results, that is, the sql1 query result is the parent record set, and the sql2 query result is the subrecord set.

This method can be divided into two types: link level and parameterized level.

Link level example: Shape {select a, B from T1} append ({select M, N from T2} relate a = m)

Parameterized hierarchy example: Shape {select a, B from T1} append ({select M, N from T2 where M = ?} Relate A to parameter 0)

It can be seen that there is a where M =? And a parameter 0

This function starts from the same level as the previous link level, but only works in different ways. In this case, the data is not planted at one time, and only the data in the parent record set is retrieved, the subrecord set is only retrieved when you open a record set based on the chapter field.

Example:

<%

Set DB = server. Createobject ("ADODB. Connection ")
Set rs = server. Createobject ("ADODB. recordset ")
Mmm = "driver = {SQL Server}; server = 192.1.1.21; uid = sa; Pwd = myself; database = gwjp2"
DB. provider = "msdatashape"
DB. Open Mmm

Rs. Open "shape {select name, ID from TGW} append ({select name, gwid from tren} As Liu relate ID to gwid) as Liu", DB, 3, 1

Response. Write Rs. recordcount
Response. Write "<HR>"
Do while not Rs. EOF
Response. Write "job name:" & RS (0)
Set QQ = RS ("Liu"). Value
Response. Write "<br> Number of Records" & QQ. recordcount & ": <br>"
Do while not QQ. EOF
For I = 0 to QQ. Fields. Count-1
Response. Write QQ (I) & "|"
Next
Response. Write "<br>"
QQ. movenext
Loop
Response. Write "<br>"
Response. Write "<HR>"
Rs. movenext
Loop
%>

The execution result is:

42
--------------------------------------------------------------------------------
Job name: Network System Management B
Number of records 0:

--------------------------------------------------------------------------------
Job title: Application Software Development J
Number of records 2:
Name 1 | 9 |
Name 2 | 9 |

--------------------------------------------------------------------------------
Position: Stock Market Analysis
Number of records 0:

--------------------------------------------------------------------------------
Job name: photocopier
Number of records 4:
Name 3 | 68 |
Name 4 | 68 |
Name 5 | 68 |
Name 6 | 68 |

--------------------------------------------------------------------------------
Position: Patrol B
Number of records 1:
Name 7 | 69 |

--------------------------------------------------------------------------------
Position: after-sales service station director H
Number of records 1:
The name is 8 | 111 |

--------------------------------------------------------------------------------
Position: field technical diagnosis d
Number of records 1:
The name is 9 | 121 |

--------------------------------------------------------------------------------
Position: field technical diagnosis g
Number of records 3:
Name: 10 | 123 |
Name: 11 | 123 |
Name 12 | 123 |

--------------------------------------------------------------------------------
Position: law enforcement supervision B
Number of records 0:

--------------------------------------------------------------------------------
Position name: Cleaning
Number of records 3:
Name 13 | 152 |
Name: 14 | 152 |
Name: 15 | 152 |

--------------------------------------------------------------------------------
Job name: Quality System
Number of records 1:
Name 16 | 160 |

--------------------------------------------------------------------------------
Position name: outsourced parts inspection B
Number of records 2:
Name: 17 | 206 |
The name is 18 | 206 |

--------------------------------------------------------------------------------
Position name: mechanical and electrical parts inspection C
Number of records 2:
Name 19 | 207 |
Name 20 | 207 |

--------------------------------------------------------------------------------
Position name: Research Secretary d
Number of records 1:
The name is 21 | 216 |

--------------------------------------------------------------------------------
Position: Policy Research B
Number of records 0:

--------------------------------------------------------------------------------
Job name: typing and copying C
Number of records 1:
The name is 22 | 280 |

--------------------------------------------------------------------------------
Job name: Warehouse Management
Number of records 4:
The name is 23 | 485 |
Name: 24 | 485 |
Name: 25 | 485 |
The name is 26 | 485 |

--------------------------------------------------------------------------------
Position name: Financial Analysis
Number of records 0:

--------------------------------------------------------------------------------
Job name: green technology management
Number of records 1:
Name 27 | 560 |

--------------------------------------------------------------------------------
Job name: Green Technology Management B
Number of records 3:
Name 28 | 592 |
Name 29 | 592 |
Name 30 | 592 |

--------------------------------------------------------------------------------
Job name: Total duty scheduling d
Number of records 3:
Name 31 | 627 |
Name 32 | 627 |
Name 33 | 627 |

--------------------------------------------------------------------------------
Job name: Production Scheduling L
Number of records 2:
Name 34 | 628 |
The name is 35 | 628 |

--------------------------------------------------------------------------------
Position name: Environmental testing
Number of records 1:
Name: 36 | 651 |

--------------------------------------------------------------------------------
Position name: Environmental Testing B
Number of records 2:
Name 37 | 652 |
Name 38 | 652 |

--------------------------------------------------------------------------------
Position: Asset Management
Number of records 2:
Name 39 | 665 |
Name: 40 | 665 |

--------------------------------------------------------------------------------
Position: Energy outsourcing and outreach
Number of records 1:
Name: 41 | 667 |

--------------------------------------------------------------------------------
Position: Energy Monitoring and Arbitration
Number of records 5:
Parameter 42 | 682 |
Name 43 | 682 |
Name 44 | 682 |
Name: 45 | 682 |
Name 46 | 682 |

--------------------------------------------------------------------------------
Title: dongmen guard Co., F-I.
Number of records 7:
Name 47 | 747 |
Name 48 | 747 |
Name 49 | 747 |
Name: 50 | 747 |
Name 51 | 747 |
The name is 52 | 747 |
Name 53 | 747 |

--------------------------------------------------------------------------------
Position: south door guard G-I
Number of records 5:
Name 54 | 749 |
Name 55 | 749 |
Name 56 | 749 |
Name 57 | 749 |
Name 58 | 749 |

--------------------------------------------------------------------------------
Position name: Material door guard I
Number of records 1:
The name is 59 | 751 |

--------------------------------------------------------------------------------
Position name: Simon guard H, I
Number of records 2:
Name: 60 | 753 |
The name is 61 | 753 |

--------------------------------------------------------------------------------
Position name: change location to car point guard B
Number of records 1:
Name 62 | 757 |

--------------------------------------------------------------------------------
Position name: South warehouse guard
Number of records 3:
Name 63 | 759 |
Name 64 | 759 |
Name 65 | 759 |

--------------------------------------------------------------------------------
Position name: dedicated wire door guard B-D
Number of records 7:
Name 66 | 761 |
Name: 67 | 761 |
Name: 68 | 761 |
Name 69 | 761 |
The name is 70 | 761 |
Name 71 | 761 |
Name 72 | 761 |

--------------------------------------------------------------------------------
Position: Logistics Service B
Number of records 3:
Name 73 | 763 |
Name 74 | 763 |
Name 75 | 763 |

--------------------------------------------------------------------------------
Job name: Business Budget Plan
Number of records 0:

--------------------------------------------------------------------------------
Position name: Asset Management
Number of records 1:
Name 76 | 805 |

--------------------------------------------------------------------------------
Job title: metallographic examination and analysis
Number of records 2:
Name 77 | 806 |
Yang Ying | 806 |

--------------------------------------------------------------------------------
Position: patrol officer
Number of records 1:
Name 78 | 807 |

--------------------------------------------------------------------------------
Job name: Management Database
Number of records 3:
Name 79 | 808 |
Name 80 | 808 |
Name 81 | 808 |

--------------------------------------------------------------------------------
Job title: Beijing project department business organizer
Number of records 2:
Name 83 | 809 |
Name 83 | 809 |

--------------------------------------------------------------------------------
Job name: Drawing C-J
Number of records 3:
Name 84 | 810 |
Name 85 | 810 |
Name 86 | 810 |

2. Shape {sql1} as A1 compute A1 by groupfieldlist

This method is used to group sql1 query results based on groupfieldlist. Each group has a separate Word Record set. The first field in the parent record set stores the pointer of the corresponding sub-record set, and other fields in the parent record set store the value of the corresponding groupfieldlist.

Example:

<%
Set DB = server. Createobject ("ADODB. Connection ")
Set rs = server. Createobject ("ADODB. recordset ")
Mmm = "driver = {SQL Server}; server = 192.1.1.21; uid = sa; Pwd = myself; database = gwjp2"
DB. provider = "msdatashape"
DB. Open Mmm

Rs. Open "shape {select dwname, gwlevel from tzl order by dwname} As DDD compute DDD by dwname, gwlevel", DB, 3,1
Response. Write Rs. recordcount
Response. Write "<HR>"
Do while not Rs. EOF

Tt = ""
For I = 1 to Rs. Fields. Count-1
Tt = TT & "& RS (I)
Next
Set QQ = RS (0). Value
Response. Write "<font color = ff0000>" & TT & "---------" & QQ. recordcount & "<br> </font>"
Do while not QQ. EOF
For I = 0 to QQ. Fields. Count-1
Response. Write QQ (I) & "===="
Next
Response. Write "<br>"
QQ. movenext
Loop
Response. Write "<HR>"
Rs. movenext
Loop
%>

 

The execution result is:

24
--------------------------------------------------------------------------------
XX Company production and manufacturing department 13 --------- 2
XX Company production and manufacturing department ===13 ====
XX Company production and manufacturing department ===13 ====

--------------------------------------------------------------------------------
XX company manufacturing department 35 --------- 2
XX Company production and manufacturing department ===35 ====
XX Company production and manufacturing department ===35 ====

--------------------------------------------------------------------------------
XX company manufacturing department 39 --------- 2
XX Company production and manufacturing department ===39 ====
XX Company production and manufacturing department ===39 ====

--------------------------------------------------------------------------------
XX Company marketing department 9 --------- 1
XX Company Market 1 = 9 =

--------------------------------------------------------------------------------
XX Company marketing department 14 --------- 1
XX Company Market 1 = 14 =

--------------------------------------------------------------------------------
XX Company marketing department 37 --------- 1
XX Company Market 1 = 37 =

--------------------------------------------------------------------------------
XX Company market division 40 --------- 1
XX Company marketing department ===40 ====

--------------------------------------------------------------------------------
XX Company marketing department 45 --------- 1
XX Company marketing department ===45 ====

--------------------------------------------------------------------------------
XX Company Asset Operations Department 9 --------- 1
XX Company Asset Operations Department ===9 ====

--------------------------------------------------------------------------------
XX Company Asset Operations Department 39 --------- 2
XX Company Asset Operations Department ===39 ====
XX Company Asset Operations Department ===39 ====

--------------------------------------------------------------------------------
XX Company Asset Operations Department 41 --------- 1
XX Company asset Operation Department ===41 ====

--------------------------------------------------------------------------------
XX Company General Security Department 9 --------- 1
XX Company Comprehensive Support Department ===9 ====

--------------------------------------------------------------------------------
XX Company General Security Department 14 --------- 4
XX Company's Comprehensive Support Department ===14 ====
XX Company's Comprehensive Support Department ===14 ====
XX Company's Comprehensive Support Department ===14 ====
XX Company's Comprehensive Support Department ===14 ====

--------------------------------------------------------------------------------
XX Company General Security Department 15 --------- 1
XX Company's Comprehensive Support Department ===15 ====

--------------------------------------------------------------------------------
XX Company Comprehensive Support Department 17 --------- 6
XX Company's Comprehensive Support Department ===17 ====
XX Company's Comprehensive Support Department ===17 ====
XX Company's Comprehensive Support Department ===17 ====
XX Company's Comprehensive Support Department ===17 ====
XX Company's Comprehensive Support Department ===17 ====
XX Company's Comprehensive Support Department ===17 ====

--------------------------------------------------------------------------------
XX Company General Security Department 18 --------- 3
XX Company Comprehensive Support Department ===18 ====
XX Company Comprehensive Support Department ===18 ====
XX Company Comprehensive Support Department ===18 ====

--------------------------------------------------------------------------------
Quality Assurance Department measurement department 15 --------- 1
Measurement area of Quality Assurance Department ===15 ====

--------------------------------------------------------------------------------
Quality Assurance Department Quality Management Office 26 --------- 2
Quality Assurance Department Quality Management Office ===26 ====
Quality Assurance Department Quality Management Office ===26 ====

--------------------------------------------------------------------------------
Quality Assurance Department Quality Management Office 41 --------- 1
Quality Assurance Department Quality Management Office ===41 ====

--------------------------------------------------------------------------------
Enterprise Management Information Center 41 --------- 1
Information Center of the enterprise management department ===41 ====

--------------------------------------------------------------------------------
R & D center metro bus Development Department 9 --------- 1
R & D center Urban Rail Passenger Car Development Department ===9 ====

--------------------------------------------------------------------------------
R & D center archives 9 --------- 1
R & D center archives ===9 ====

--------------------------------------------------------------------------------
R & D center archives 16 --------- 1
R & D center archives ===16 ====

--------------------------------------------------------------------------------
R & D center archives 18 --------- 1
R & D center archives ===18 ====

 

Summary: The above example is very superficial and mainly used for getting started. In fact, these layers can be very complex. We generally do not use these complex layers here. If necessary, I can check some materials, but I tried to write a complex hierarchy, but I was not successful. I encountered some problems that I had not seen before and could not solve.

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.