|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
, \7 b2 Z: E h
" C4 Y5 O0 W* N; i2 D: M J; L/ e* t5 M6 t; B# T3 \4 S* M
Technique . Y; v( i/ G6 \% [) Y* F8 \9 }
Use the Innovator.applySQL( … ) method to submit SQL direct to the database. This
; V8 u" g G& H0 zrecipe returns the XML from the applySQL() method and forms HTML for a table to
& r, A8 }- H: w4 J; Zdisplay the data. & w7 S! t! N% O
: @- U2 o @+ b
4 ], H) s( s1 ?+ V/ UC# : ~# l2 a5 K! U/ g; E7 y) G
Innovator myInnovator = this.newInnovator();
+ K" c" C6 q; @0 t+ VItem results = myInnovator.applySQL(
t# r9 f4 k0 T1 _' u7 `. A "select login_name,first_name,last_name,email " +
% k$ C1 C* R* K% x& o+ s$ d "from [user] " + / R/ m' Q# Q; u" c2 {) z$ b
"order by last_name,first_name"); % q5 \" y% R# Q; t8 Q
7 T; C* z; j x* Q2 Kstring content = "" +
! U1 j) h8 P. Q* ]4 m "<style type='text/css'>" +
; X, X: F* Z3 J$ D+ w# h% Z "table {background:#000000;}" + " y0 ?; R( C" i
"th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" +
3 }1 O0 c6 G& d3 s8 Y "td {font:normal 10pt Verdana; background:#FFFFFF;}" +
" J \7 N# B2 p$ d( ]- e: V4 | "caption {font:bold 14pt Verdana; text-align:left;}" +
$ H9 }; \8 M5 s: x% i4 I- C. P V "</style>" +
* E& H- y! R& ~9 J "<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
# w! l6 j! S& d# c5 J! E "<caption>User Directory</caption>" +
/ t; b0 x1 v8 D- a6 U Z+ ] "<thead>" + + v3 x3 I/ H7 W& u- j
"<tr>" + ( m4 t; G& ?5 T' i. q" `
"<th>Login Name</th>" +
0 X6 j. O# L; h$ | "<th>First Name</th>" + # V- N0 M+ w' O; S' ^& @
"<th>Last Name</th>" + ( w# G9 ]" ^1 `2 W3 w7 J
"<th>EMail</th>" + 5 w7 m9 @! S( \3 f
"</tr>" +
- |2 O6 M% @$ {/ a "</thead>" + 6 t' |2 a+ A# L; k' z, |- i+ t. c# ^
"<tbody>";
7 i$ g3 D$ V' H" E, m% r% ] " W1 z- Z* h: K$ U# q
XmlNodeList users = results.dom.SelectNodes("//recordset/row");
" q; |& w$ ` _0 u$ `: Nfor (int i=0; i<users.Count; i++) {
3 X; U: Z# n1 {* f" N) f content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?
! |' p% s4 \; c2 I5 j! y users.SelectSingleNode("login_name").InnerText : "") + "</td>";
. k4 C# j B: f
# _9 w/ t1 D6 \ content += "<td>" + ((users.SelectSingleNode("first_name") != null) ?
. i% K" k4 F! u% s Z/ P7 D users.SelectSingleNode("first_name").InnerText : "") + "</td>";
$ ?0 Z5 ~8 }$ I5 ?
" K8 o4 u) g2 j; X/ l content += "<td>" + ((users.SelectSingleNode("last_name") != null) ?
* k8 O9 }/ U+ N, d0 S( a- _ users.SelectSingleNode("last_name").InnerText : "") + "</td>";
" P' B8 _4 u9 m6 h3 Z& L+ K " j0 s* Q1 d( V7 h( N
content += "<td>" + ((users.SelectSingleNode("email") != null) ?
$ j, \4 Y# R0 a) M* e% g. e users.SelectSingleNode("email").InnerText : "") + "</td></tr>"; # p `4 V4 P7 Y2 O
/ o- Y6 D8 R* m) d" E$ ~} 9 s g- Z7 G1 f) Y. p1 S$ B$ I
) c2 J' O. m, q; C) o; U2 f
content += "" +
& g( N" c% H+ b6 T/ `! H "</tbody>" +
8 l6 }, V: A# k. x, R "</table>";
: d$ f$ Z) ~" @# w) T0 _8 j
( Q% a% a# e* W7 o4 L! _5 preturn myInnovator.newResult(content);
9 |, ^4 A$ C' Q' a3 F# H) T+ n: \' D! w" w- k9 A; \
|
|