|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
7 u8 M& `6 f: Z# ]( D" u
( h: o6 \6 g5 f" R& j
1 b6 a- N# w/ i1 V0 a% q1 |5 oTechnique
0 r" y2 A( H! F4 U' qUse the Innovator.applySQL( … ) method to submit SQL direct to the database. This : A$ ?' S/ ?$ S" D1 X1 \2 i% Z' _
recipe returns the XML from the applySQL() method and forms HTML for a table to 0 g! I) p9 q# `& d1 x
display the data. - P' c4 o$ t2 O$ N( p1 v4 }
# J; U8 y8 A! a1 j" ~: X L/ U: s8 G0 }5 J6 x1 G
C# 9 e. e9 o1 y O& H E6 N
Innovator myInnovator = this.newInnovator(); 6 K* ^% L) [# D
Item results = myInnovator.applySQL( % |' I z. L+ L3 e- j
"select login_name,first_name,last_name,email " + & [/ w3 D) h& {' m6 @# V
"from [user] " + 7 p& R- S' T" ]3 ?
"order by last_name,first_name");
6 }* v3 w4 O( w4 [9 ?
8 K1 j W; M( {( t; cstring content = "" + 7 m6 @2 n; |5 b; M: l6 ]
"<style type='text/css'>" + - s8 ^* Y$ j" y; b% G* a
"table {background:#000000;}" + ; I+ {1 }6 X: C) r) `# i
"th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + $ Z; |: b5 g! O. H
"td {font:normal 10pt Verdana; background:#FFFFFF;}" + 9 {( D6 p- ?3 a7 {8 r" J. m- H- |
"caption {font:bold 14pt Verdana; text-align:left;}" + ) G! n# j* }" T( c* h9 f- f$ e
"</style>" + w- ?7 r2 ?1 C ?& [6 v6 k# B
"<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
7 a' C3 b ~$ j% D: u; x "<caption>User Directory</caption>" + $ y/ ]1 q4 t9 V5 y- L+ R; @7 l; p
"<thead>" + . x8 S b) T' c! }1 g; G
"<tr>" + , Z6 P7 g# S' m& @' L6 N5 ^, J7 ^
"<th>Login Name</th>" + 7 s0 p& f. B1 h; } H
"<th>First Name</th>" + - t/ o. A" M8 ]
"<th>Last Name</th>" + 6 @& d6 I: m+ g6 n
"<th>EMail</th>" +
8 [) }% T& M0 ~0 A- r9 ^ "</tr>" + % |2 t$ H, P9 C; N
"</thead>" + # a) c2 w# L$ ~: V
"<tbody>"; ; K0 D1 e7 l& X; p
- i; _4 Y f+ ~' A# h6 IXmlNodeList users = results.dom.SelectNodes("//recordset/row");
! _- l2 B1 J; ^& ?, s. h, zfor (int i=0; i<users.Count; i++) { ) I% `' q( I8 J _1 b* P7 i
content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?
( L' e, y/ k: W1 S users.SelectSingleNode("login_name").InnerText : "") + "</td>";
9 Y5 k; L# I8 r4 [2 ` / ]0 j3 O1 j) r7 s$ H$ [+ j
content += "<td>" + ((users.SelectSingleNode("first_name") != null) ? # {9 C* K! I- @5 u8 }9 P6 G' J
users.SelectSingleNode("first_name").InnerText : "") + "</td>"; % r4 w5 }. Y; J
% M/ y; ?+ ?* F8 V content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? , n6 n. S4 Z; T+ A6 n. R) a* j
users.SelectSingleNode("last_name").InnerText : "") + "</td>"; 5 w/ t8 R3 z- H( e
/ x! i" T2 l! i- i: h content += "<td>" + ((users.SelectSingleNode("email") != null) ?
5 U9 M' f2 O: ~$ g. d) w' b users.SelectSingleNode("email").InnerText : "") + "</td></tr>"; 2 P" c ^# ^! G5 F6 J/ T
# F& s8 K" x% t/ C9 H
}
* e* u/ y# s0 X, l
) r4 n7 h7 e$ i. Qcontent += "" + ; {0 @' e/ l$ i2 n( p) {& n
"</tbody>" +
/ s5 ~7 z9 x) N$ q "</table>"; . {0 d! `% F! {2 W
6 m) z. F3 k8 B9 K6 w3 n2 R
return myInnovator.newResult(content); # S+ u( I$ B& e) y1 P
0 _# x; J, M) b |
|