|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
: d8 @; C( g$ h' r
. \( W( Z7 Q2 w& Q- D5 Z
( q1 y. f- Y4 i& y B7 l6 STechnique
( t1 b. U$ r z# ]4 F7 rUse the Innovator.applySQL( … ) method to submit SQL direct to the database. This
$ H; m8 u _7 v: Z" d* _9 grecipe returns the XML from the applySQL() method and forms HTML for a table to
8 V" u+ c0 x! [7 _" o" m0 D( P* G" Adisplay the data. & _8 p9 v. k3 b/ L7 h: f
1 l9 |+ v0 I9 n1 f+ s% U. D0 i
- `& F; Q/ u- U. G+ ^& P
C# - m( m1 M% P7 I% S- `4 B$ c8 e$ |
Innovator myInnovator = this.newInnovator(); 1 O. H `! u* F! [
Item results = myInnovator.applySQL(
6 C! z" L/ R5 F o' [1 R5 R6 c "select login_name,first_name,last_name,email " +
, e6 @5 o) w6 }$ q7 s/ C "from [user] " + 8 x( r+ y( L2 Z
"order by last_name,first_name");
& G1 ^8 F: f: Q
5 J2 |; |; F5 v' q( v' r/ lstring content = "" + 3 _ O& G/ l! F6 D. H7 [" H* o2 j
"<style type='text/css'>" +
* {" _5 o: d/ Q( L. u+ j& V, b0 j "table {background:#000000;}" + 5 t4 D6 g \! M: w# D
"th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" +
. C! @# c; p( z5 x) w1 a; t "td {font:normal 10pt Verdana; background:#FFFFFF;}" +
8 b6 _: R5 [0 ]0 s$ W& h "caption {font:bold 14pt Verdana; text-align:left;}" + . Y2 }$ D* ?$ \
"</style>" + $ J& m* A: t. B! S8 d' z
"<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" + % r0 E/ n, b0 e6 C& t) R
"<caption>User Directory</caption>" +
# B; f3 p9 N5 q3 e) \& O- h! k "<thead>" +
* |# P1 }2 c; u "<tr>" +
3 s S4 ^+ g7 Q, u9 ?( B7 S "<th>Login Name</th>" +
0 D6 a* O. l1 ~ "<th>First Name</th>" + 5 M0 a# s* K- ?: x( i- T4 G0 G1 ]
"<th>Last Name</th>" +
1 E( a, T V7 F) d "<th>EMail</th>" +
" @3 q" u; z) J. u2 k$ j8 g "</tr>" + : Y. a' a! m1 R: D9 G1 ?5 n. _
"</thead>" +
- c; x' b* F: x "<tbody>";
8 K7 [- I6 e& d. Z% _1 s % d# H& [2 ~0 n4 `& e
XmlNodeList users = results.dom.SelectNodes("//recordset/row"); 7 o- X& O5 H0 N
for (int i=0; i<users.Count; i++) {
- G2 A9 C: b2 ^3 n0 _ content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ? & R6 O$ M0 W) X' p8 Z0 o" L3 j
users.SelectSingleNode("login_name").InnerText : "") + "</td>";
: F! G6 i& W: \5 }
2 n: n/ H5 z' n0 u, q content += "<td>" + ((users.SelectSingleNode("first_name") != null) ?
5 [: J" O/ ? X% _& Y$ \ users.SelectSingleNode("first_name").InnerText : "") + "</td>";
) w1 ]( t2 F: x# f% y! f 6 A: N7 ]- S/ }6 |0 }- c
content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? " o6 F+ m: C2 \7 Z. O( H
users.SelectSingleNode("last_name").InnerText : "") + "</td>"; 3 I9 \! l" a2 |
- X0 E, r# \* Z
content += "<td>" + ((users.SelectSingleNode("email") != null) ? ' W: \4 `* [1 J
users.SelectSingleNode("email").InnerText : "") + "</td></tr>"; ! C7 U, G, Z' e: W9 l; G8 N
! q# Y0 o1 m5 E/ `
} ) _. J4 _+ m! y& [/ B! T/ x
( Y0 p8 L5 S! q9 c/ t
content += "" + - y2 f% k' o2 ]( b
"</tbody>" + . Z# z2 F5 _6 I1 x* s8 G) W
"</table>";
- v. B0 X/ Q/ {* C . @- W4 J$ s& c: {, i, A4 o
return myInnovator.newResult(content);
( E4 z( U; e! i! U8 Y" R( A% W! M4 k3 l, a7 b T6 @+ \4 Z
|
|