|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! n8 W r$ S. z) A3 Z' q* a
7 W, @& C) w" X4 R5 b
* O. J- t M6 w0 l& Z+ I
Technique + w! W3 _; ]& v; O4 W7 W6 w
Use the Innovator.applySQL( … ) method to submit SQL direct to the database. This 7 s$ B f, G1 J
recipe returns the XML from the applySQL() method and forms HTML for a table to ; X9 R9 V8 N% ^/ F+ k& C2 l# b) ?
display the data. % {& G9 z3 ?0 x
2 b( s6 l4 y+ h: m8 G3 v+ b9 b# E) f! O3 g o. t& `
C# 5 n9 L* Q! O( e: i: l, e
Innovator myInnovator = this.newInnovator(); # C! A m& G& j$ Z* T: d* R7 T, m
Item results = myInnovator.applySQL(
) c: M8 [$ H5 K5 _8 d" M% S "select login_name,first_name,last_name,email " +
7 w! g. [4 ]9 e$ R "from [user] " +
, f3 h3 @# K) b: w% D9 Q' @6 F* ? "order by last_name,first_name");
% I/ A# J2 |9 K" |; @
! }) u9 U# r8 ?& ]0 N" T3 sstring content = "" +
" T: m" U: V& D "<style type='text/css'>" +
7 i( k% A) O$ a$ }6 e "table {background:#000000;}" + / N# [, |! @5 ?9 r- |1 Z2 E
"th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + , [- n- A) k& Q. C) ^
"td {font:normal 10pt Verdana; background:#FFFFFF;}" +
1 |3 m" q" `' q ]$ h "caption {font:bold 14pt Verdana; text-align:left;}" +
6 _& e7 A1 `; i7 }: @0 |0 i& B "</style>" + % F* U% q! ^% S7 D I
"<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
# n1 D5 }4 L& \/ V" ]+ T% B5 ~8 P0 B "<caption>User Directory</caption>" + 6 O# c# G& P- x$ k
"<thead>" +
5 }: M/ V% w9 p "<tr>" +
9 \5 @9 p! P; o- l/ ~: I" a% F" H" K "<th>Login Name</th>" +
U) |4 m; c; K/ _5 a; W. }5 w+ G "<th>First Name</th>" +
* D- x% i. P9 L: w "<th>Last Name</th>" +
+ C. V8 J4 K2 W4 B$ G "<th>EMail</th>" + 8 j* j9 O% s! f6 r- Z5 [( R) K
"</tr>" +
# T& |. A* V1 O1 |+ C/ ^* J "</thead>" +
: c. C; ^6 W. R$ L8 D/ E8 @! h w "<tbody>"; * x! V4 @( }) L, y% {& _
5 S( j y7 ~2 I" a; F& P: @
XmlNodeList users = results.dom.SelectNodes("//recordset/row"); 1 J c Z# k& G/ O
for (int i=0; i<users.Count; i++) { 4 H! E0 l! u) m- _( w% T
content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ? 1 P0 J) I9 M W2 L
users.SelectSingleNode("login_name").InnerText : "") + "</td>";
' A, O& B+ ?# v7 _) c 7 O0 O7 z1 G; v0 M& [& M
content += "<td>" + ((users.SelectSingleNode("first_name") != null) ?
' R" h" i: V& f users.SelectSingleNode("first_name").InnerText : "") + "</td>"; 9 f, v$ f; \/ Y( B$ E! j( `
8 i( y+ f" S) r2 J1 ]
content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? 8 \+ V, ^. F0 D9 u( A; S
users.SelectSingleNode("last_name").InnerText : "") + "</td>";
) J" Z0 |) G* g- c; Q % `: M0 M5 u! `8 P% P
content += "<td>" + ((users.SelectSingleNode("email") != null) ? # U" o0 \9 \- y+ V
users.SelectSingleNode("email").InnerText : "") + "</td></tr>"; + F+ f [0 f: {# o* O5 y
7 `' ~3 u/ W/ x
} ( c3 y p( u: A: z1 X+ r2 ^
: n1 y: V& y) f4 M) `
content += "" +
1 k+ G/ U* @3 p "</tbody>" + . `4 d" Z- u7 Y( H
"</table>"; 9 L* Y# i& l. i8 E( h! s. I
! |7 w- V( H. ureturn myInnovator.newResult(content);
5 u4 ~( j( N2 M0 O8 ?; l; f7 w( W% o
|
|