|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
( J5 b3 x6 W6 c8 G |/ n0 G' o: R
# g( e, G, W# N, U6 \3 u! V& p
2 P6 A$ H& a' Q1 D% p1 g9 Z) eTechnique : E' n! v. k8 e- T/ ]4 }& B* o: O2 \" k, Y
Use the Innovator.applySQL( … ) method to submit SQL direct to the database. This / Q& F' ~- U7 y. Z' I$ }
recipe returns the XML from the applySQL() method and forms HTML for a table to % E3 b& A. T6 l, M
display the data.
5 D, @9 H: @8 a2 c
# P4 k- N4 @. q6 a }
$ M9 E2 n4 l5 m1 R' F" gC# % ~0 @% o7 J. \6 q/ `
Innovator myInnovator = this.newInnovator(); " d1 k8 x& J$ z0 A. s' Z; u- G
Item results = myInnovator.applySQL(
6 X6 f. x Z, V' c- J "select login_name,first_name,last_name,email " +
4 \7 e/ \' V7 j0 C "from [user] " +
5 f8 X! r& I1 O! V "order by last_name,first_name");
' T$ G% L/ \: g! ~2 G# W! [
9 F3 b% M0 t8 j0 Q, Sstring content = "" + 6 D, R4 W! t$ }, l. ]& z
"<style type='text/css'>" + 6 ^8 y8 u: x( k- L+ g) t+ I# B
"table {background:#000000;}" +
' G/ b0 G- O+ F; c "th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + # x) E; U6 u: a$ v
"td {font:normal 10pt Verdana; background:#FFFFFF;}" + + V% O A" E# @- s3 C
"caption {font:bold 14pt Verdana; text-align:left;}" + : U: R+ V- o7 w4 u3 c w5 ^
"</style>" +
. c7 i$ _/ K2 D, D) R8 V "<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" + + F& V" H; N" X. U C
"<caption>User Directory</caption>" + 7 E/ `! \* G& e, K
"<thead>" +
* S5 L9 a9 W( o/ a: @8 L "<tr>" + 2 h ~0 {- P/ u A2 B
"<th>Login Name</th>" + + s' D" O2 l6 n. e
"<th>First Name</th>" +
8 s# x$ c6 O, f4 b# j "<th>Last Name</th>" + 9 ]4 ^- \5 K- \& x" M" s
"<th>EMail</th>" +
9 K( T' S0 h, k- x! X% d "</tr>" + ( L! Q. o, {, P! v
"</thead>" + $ u4 |. ?1 L" W$ s6 A Z& u
"<tbody>";
" ^3 F2 L9 u- m0 b! R. P7 s 9 W# q; I" a* ^# D8 s0 z) v; `7 I+ s' G7 r
XmlNodeList users = results.dom.SelectNodes("//recordset/row"); 5 {) b9 z$ b4 Q4 _& \
for (int i=0; i<users.Count; i++) { " |: h; g: V4 b' H/ n. ]
content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ? 8 ` w$ ^4 N" c& T' ?
users.SelectSingleNode("login_name").InnerText : "") + "</td>"; 4 G, K z4 r; |$ r# T: T2 M$ I$ u% \
% E3 F& S# ~2 \7 `: o( q( |1 m
content += "<td>" + ((users.SelectSingleNode("first_name") != null) ? 8 ?2 h' i0 d7 A, ^6 `- s. h
users.SelectSingleNode("first_name").InnerText : "") + "</td>";
; H A/ R) s1 N! N, p6 | # ~( M# ]2 M1 ?
content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? i! S" A+ {: K4 s* T& m
users.SelectSingleNode("last_name").InnerText : "") + "</td>"; * J% l5 H: P9 M* T% \% G
* r& S) d8 q+ R( i content += "<td>" + ((users.SelectSingleNode("email") != null) ?
^1 z9 |& j8 Q( G2 \4 t" t+ Q users.SelectSingleNode("email").InnerText : "") + "</td></tr>";
; _# S) t: Y) @4 Y8 D; ]* s
1 Y8 l8 m; V2 R3 f/ N- G& M}
2 ~! k, |: o+ G3 ?4 @
* v" M$ u& g" q$ _4 W+ p: [content += "" +
2 y, x% l, i6 ^0 l "</tbody>" + 3 [- |; ~9 @+ O) f. e7 h
"</table>";
+ ]% ~4 u9 y1 ^+ H* B6 d 3 |1 ^( Y8 Z3 ?3 O0 ?
return myInnovator.newResult(content); ' i `+ A; o- B4 A
( I& z& ]3 C2 n+ Y, D
|
|