|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 h( n$ K8 u2 E& u2 G( C1 Z# e* I
@- ]7 {4 z+ k' @$ k( x9 }4 k
Technique
) Y3 }4 S) i9 l; d6 |Use the Innovator.applySQL( … ) method to submit SQL direct to the database. This
]4 ^- C9 H8 ~1 b9 }recipe returns the XML from the applySQL() method and forms HTML for a table to 2 N5 f4 ?+ e9 O; e$ p
display the data. % e: h4 [# Q6 z0 h" v* G% i
8 e5 q/ ^2 i: ^3 N; T; P
: O; ~" g; i3 O7 [5 H3 @- }C# 0 G3 p: n: {( X
Innovator myInnovator = this.newInnovator(); " C0 S9 a9 T5 a5 {. t* J, }
Item results = myInnovator.applySQL(
5 [; i: v( E. C& E- y "select login_name,first_name,last_name,email " +
0 v8 e. B/ z6 {- q "from [user] " +
) m5 K( h- i6 a7 A- p. T "order by last_name,first_name"); $ h- v4 J+ H0 C; A
+ s3 ]4 h5 f! L0 y0 F( q& R. Tstring content = "" +
& l \6 q# @' L' y "<style type='text/css'>" + 6 R3 R$ B# `' V- P8 G% P# E
"table {background:#000000;}" + & Z0 S! s" H* e% c/ b1 X9 z7 k5 y( b
"th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + 4 `7 x* y' v0 r; s% H1 Q8 A
"td {font:normal 10pt Verdana; background:#FFFFFF;}" + / U1 R$ g, N+ k3 {; H
"caption {font:bold 14pt Verdana; text-align:left;}" +
+ f. l, d) j8 ?+ n# H "</style>" + X, r1 y. j! `( E7 z' e
"<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" + # J6 ]- o* D( f) a* h1 w- E
"<caption>User Directory</caption>" +
' E5 K# [9 l$ e! ~7 @5 l4 Q "<thead>" +
0 K% z! C2 L( }) w4 ?3 N "<tr>" +
2 B8 ]' X/ d( s "<th>Login Name</th>" + J" u# m/ W' E' O
"<th>First Name</th>" + . a7 N) D' ] B" Z1 Z0 B8 n
"<th>Last Name</th>" +
( m( ^! Z1 P( E "<th>EMail</th>" +
+ [: Y! l; H2 G; h) w# d$ j "</tr>" +
0 j, g u+ p9 r "</thead>" + 1 c7 W$ z! T u, D0 @3 M6 |! R
"<tbody>";
, Y" h! m8 \; b
; j& p* l# @% a% F! CXmlNodeList users = results.dom.SelectNodes("//recordset/row");
- k" b6 t3 D' G0 Gfor (int i=0; i<users.Count; i++) { & x6 f L: }2 V$ Z8 H* _
content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?
$ \" E3 O: T7 L/ h) @1 k users.SelectSingleNode("login_name").InnerText : "") + "</td>"; 4 R5 S3 c! n1 R* M( ~$ S6 q
2 c, l* L1 G4 @7 B content += "<td>" + ((users.SelectSingleNode("first_name") != null) ? 2 O( a1 e+ w' p6 @; Z r
users.SelectSingleNode("first_name").InnerText : "") + "</td>"; / M6 n' Y6 r1 ?4 h7 X. d4 a
3 B# }/ R$ a9 o5 g- m1 z content += "<td>" + ((users.SelectSingleNode("last_name") != null) ?
+ O- h7 S2 P$ X0 N/ j, r# ]7 _ users.SelectSingleNode("last_name").InnerText : "") + "</td>";
, ^( ?* Z8 R: y8 v7 ^
& _! a; h t; _" ] content += "<td>" + ((users.SelectSingleNode("email") != null) ? 0 h6 j c$ ~6 w( V, {
users.SelectSingleNode("email").InnerText : "") + "</td></tr>";
$ X& v2 S; S0 r: F+ i! j' P7 { 9 _' j6 S7 R/ {) G( f
}
0 q6 l, f2 q# f! k# n' \ . A. ~/ [$ f' s1 L4 u) Y D* n
content += "" +
0 y3 }" f, i5 `% N/ } "</tbody>" + + r& F9 y. C" B; `3 q0 c8 P
"</table>"; 4 `9 _' ~) ?- K5 v* U2 f' E
# S# _5 j6 X, Q+ N" g Y2 `7 \
return myInnovator.newResult(content); . {, d8 \* ^4 a! Y: w8 e
' m* n1 h. h& x3 [6 W3 L: D, J% ? |
|