|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
2 {3 |+ p- |( y. p+ Q+ a) }
. o: s3 t4 z4 H" U1 A5 q8 t, R# p( J$ @& l2 K
Technique 3 U, c; ?" b) E, K$ f1 t$ v
Use the Innovator.applySQL( … ) method to submit SQL direct to the database. This
) f6 ?/ W" [. B- I" F4 _recipe returns the XML from the applySQL() method and forms HTML for a table to ( h" a V' v+ E* b( g. t
display the data. " E( O- D d1 @% s
. K5 A7 s6 T4 Y- S2 Z. a1 w# n* t+ @+ c# j0 Y! q1 ]
C# 1 T& @$ ]$ y- ?3 q) {9 E
Innovator myInnovator = this.newInnovator(); # N# B$ T7 e F6 O( R3 N0 P9 R4 I
Item results = myInnovator.applySQL( - f5 o% k' C) D3 j/ ?
"select login_name,first_name,last_name,email " + 6 a& z. y$ o# j2 B3 d' R, X4 z
"from [user] " +
$ F, x9 f# U( a, e( w* q# g "order by last_name,first_name"); 6 c5 e2 C$ K% e/ U# ^# C" s, e4 u
X2 T8 g- E! u! g& \6 ~string content = "" +
4 k( f' o) m& }, w: q "<style type='text/css'>" + 2 I1 r7 J1 J! }1 G+ k# K& S
"table {background:#000000;}" + % ]# I+ s( W; ^9 \6 E5 @
"th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + : `. V9 C8 p V- Z9 r# \6 q
"td {font:normal 10pt Verdana; background:#FFFFFF;}" + : Q. n8 X5 Y- G) x' W
"caption {font:bold 14pt Verdana; text-align:left;}" + 2 b) f- A' `6 [$ n. ~& F4 Y
"</style>" +
+ x' y2 h+ P$ t \' _ "<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
. I9 O* _$ z* e9 v6 {: B" _, l "<caption>User Directory</caption>" +
$ S* H) K, S0 b- N4 a8 ~) _ "<thead>" + : s% C: |1 f# j& M
"<tr>" +
8 I$ S# S( S# X. T h "<th>Login Name</th>" + 3 ~1 J$ U; B+ S: D1 D$ `. v) i
"<th>First Name</th>" + # d# d9 G9 @+ h" F
"<th>Last Name</th>" +
G, H+ _) W- F" U7 f) o8 J( r: G "<th>EMail</th>" + + y; _# s' m- S# [- |% d
"</tr>" +
$ e# p: M2 J# m7 _4 T "</thead>" +
- t' J( D% y: V1 ? ^# B2 s$ d7 [ "<tbody>"; . A" {% } F6 P2 g" p
. G! a- E0 Q* x
XmlNodeList users = results.dom.SelectNodes("//recordset/row");
; H% Q( F% W7 wfor (int i=0; i<users.Count; i++) {
5 x( ~+ _+ L T& n content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?
: O+ Z; g. J* ]* D/ b4 G users.SelectSingleNode("login_name").InnerText : "") + "</td>"; 3 T; V, s1 j$ {* \' w. G
+ m9 ^* r7 Z1 _, h6 ~, Y8 f content += "<td>" + ((users.SelectSingleNode("first_name") != null) ? . V/ V5 L' `+ v3 i" Z
users.SelectSingleNode("first_name").InnerText : "") + "</td>";
4 X' c$ x! X: x- l' f; p
) S% b N( M$ K8 p* z- F content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? ! z1 A4 o2 x* c5 A# E- @ p
users.SelectSingleNode("last_name").InnerText : "") + "</td>"; 3 L% h9 j% Y6 t
2 L( |3 d# @; z& _
content += "<td>" + ((users.SelectSingleNode("email") != null) ?
% a) n# r$ o: t) y- g5 u users.SelectSingleNode("email").InnerText : "") + "</td></tr>";
# c6 U6 }2 U+ Y
0 \3 {. B: y% Y, D6 j; |}
- N7 e8 _1 s1 J$ _, D 0 E0 s1 X M6 X* Y
content += "" + & ~9 K9 I5 l# f6 t
"</tbody>" +
- j* j" C( y& s "</table>";
* ^4 o1 D+ s5 O) [7 {) H; j, ~9 @ , c3 H* r2 u |# @" |8 ~8 g {+ r
return myInnovator.newResult(content); ; D/ p8 t2 l3 f) J- W+ t- A
( P7 [) L: L' z3 W3 O |
|