|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
6 G' d- N7 h2 J; z6 R! D2 N1 ^9 ]8 ^
' S4 N( x2 Z# p
8 i, [+ s6 U% F6 v5 oTechnique 8 I; _! c' d& w
Use the Innovator.applySQL( … ) method to submit SQL direct to the database. This
2 {5 ] z% I& O8 rrecipe returns the XML from the applySQL() method and forms HTML for a table to 8 @1 |5 T4 m) H: U6 z" {; y
display the data.
7 W5 Q/ x' v, h/ S3 v# Y( U" M8 U, f/ ?- Y% Z( r5 C2 T
8 J& }2 [% S/ t) F# l1 w5 lC#
" [+ f' @% ?. }# R A \( {Innovator myInnovator = this.newInnovator();
, l3 N9 y* K; V! Y- E! xItem results = myInnovator.applySQL( 1 j, z( E! _, E% c
"select login_name,first_name,last_name,email " + ! n5 ~# k& v+ V6 Q. r4 M% u
"from [user] " + % @7 f r. |1 e0 Z
"order by last_name,first_name"); ( B% ]7 J: s8 ~* e
* o# W& \7 w0 e* s! U2 E
string content = "" + : \) a& ~7 m8 `0 c( A3 k
"<style type='text/css'>" + 2 t& @' K: W( S" V6 ~! U* G
"table {background:#000000;}" +
4 G- l6 d% U, R. M "th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + # i. o1 c" w! ~2 w0 W2 L
"td {font:normal 10pt Verdana; background:#FFFFFF;}" + " |/ T6 g2 G8 J( u
"caption {font:bold 14pt Verdana; text-align:left;}" + ; ]3 \9 G! k: D2 y6 W! H+ O9 w( g
"</style>" +
" U ^$ p% F$ R2 ?, B "<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" + 2 o0 a! ?( \4 [. B
"<caption>User Directory</caption>" + . J/ c* T! k6 W% ~5 Z
"<thead>" +
) j) i# t; ~0 Q7 G1 a' g. x2 Q "<tr>" + 6 B+ v+ C' ~0 Z1 p. H; |! J1 r7 z
"<th>Login Name</th>" + : _# P) S- ?3 m" _/ t
"<th>First Name</th>" +
& ]6 C: p0 ~0 T3 q y' ?; U0 R "<th>Last Name</th>" + 1 [* R+ K. o; P5 x8 D/ M: j. c# D6 u7 x
"<th>EMail</th>" +
. N! O# O. Z& `, ]) X "</tr>" + # S: c: f6 f% {1 m& @/ I
"</thead>" +
5 [9 [% p# D8 \$ F! r* x) Q$ N, s5 R "<tbody>";
3 j3 d% j/ P; m( O0 V7 u) O" A 9 ?, U, p6 t5 j: E7 S
XmlNodeList users = results.dom.SelectNodes("//recordset/row");
. Q: K l0 ` X2 L2 Cfor (int i=0; i<users.Count; i++) {
; P! V3 K, l) d content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?
) ^! ~3 ]( H( e' n users.SelectSingleNode("login_name").InnerText : "") + "</td>"; 2 F' ^* t" x q0 T3 ?% x9 h h
B6 E6 \$ ^ H1 t- P; @ content += "<td>" + ((users.SelectSingleNode("first_name") != null) ?
( Q/ x; C* T4 A- l0 H users.SelectSingleNode("first_name").InnerText : "") + "</td>";
4 r; I) T$ {6 U) f
* e# D/ V& b8 i0 }7 I content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? 5 a: g1 P2 Z3 \7 U% K
users.SelectSingleNode("last_name").InnerText : "") + "</td>";
1 _: {$ f% i7 W
' ^3 k) r1 B5 o' M% m+ o7 L content += "<td>" + ((users.SelectSingleNode("email") != null) ?
. j# `! C4 y( r; j8 D/ Y6 R users.SelectSingleNode("email").InnerText : "") + "</td></tr>"; # t" d `8 d0 v' E2 ? D& F- w
) G6 Z5 w) m# w+ [: c; \, O3 C}
: Q5 N3 @# E5 d$ G- o
0 Y2 f! e1 V$ a* Pcontent += "" + & w& q$ e1 L H( `0 g4 y) ^* J
"</tbody>" + . l3 a' ]: j S9 d3 I
"</table>";
# p: Y4 T; V: \: t! |2 A # I9 V; x% n h' c8 l) ]* X
return myInnovator.newResult(content); 1 s3 @( l4 g- E3 t; n
. r& ^; ~$ _& t+ z- H |
|