|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
- a6 p( V9 N' b. J* V' M& q
6 h; k7 b. f) B# _
4 F6 Z0 }! V# n! C2 BTechnique
5 Z, y: C3 ]4 m( }) kUse the Innovator.applySQL( … ) method to submit SQL direct to the database. This
6 d, C' {8 v' J" k5 i. O* M! |recipe returns the XML from the applySQL() method and forms HTML for a table to 6 r9 p& X3 Y; l- q2 H) P+ I
display the data. ( w6 j* l+ n# r1 P _. D
2 _! E! ^; c5 S8 ~# O; T( l% c/ x; ~
C#
3 a; t( M7 N1 \9 pInnovator myInnovator = this.newInnovator(); * N+ g9 }$ j" C# S( l
Item results = myInnovator.applySQL(
8 N" c( E7 j9 C. ^2 r" ]) l "select login_name,first_name,last_name,email " + # w$ I) s, `3 T0 S1 X' M4 z
"from [user] " +
! A) D/ {- v r0 }9 l m# _ "order by last_name,first_name"); ( I- I# K. T- h0 D1 F. P8 R) e
% N2 J6 ?+ p! \8 F
string content = "" +
( |% ]2 U9 I e$ C4 }% e "<style type='text/css'>" +
+ v9 R. x' M: u3 z, x "table {background:#000000;}" + 5 A+ m6 T7 Z, A" }" x( }; }& b
"th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + 3 g6 b/ D0 ?4 ~& C
"td {font:normal 10pt Verdana; background:#FFFFFF;}" + . c$ D9 x6 l4 ]) `' I8 }
"caption {font:bold 14pt Verdana; text-align:left;}" + 5 C, A& k) Q/ M$ p5 W+ {" m- j. Y' \6 }- z( D
"</style>" +
2 c) s1 ^3 J, ~: G% T7 f "<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
0 \: V/ d, `( w. D+ m: H "<caption>User Directory</caption>" +
% g& B! |! \0 T* a6 ~ "<thead>" + 4 W$ h, I% W9 `9 } P! }
"<tr>" +
- V" p6 L0 b9 a6 Q( X- V/ z/ d, f "<th>Login Name</th>" + ( ^0 ]0 V5 R! C/ S& W6 u0 [* Z
"<th>First Name</th>" + ( q" U: F# t& u3 e
"<th>Last Name</th>" +
4 f7 a1 P' h$ G9 ? "<th>EMail</th>" + # \$ E; E6 A; y8 x
"</tr>" +
3 z# a9 m- K2 K" P: H i "</thead>" +
. V. f" `% o+ ?% M5 c) B "<tbody>"; 4 E1 j; U i) r/ F
0 {: J: z4 D P: p& QXmlNodeList users = results.dom.SelectNodes("//recordset/row");
; _) N" l/ W- D+ Gfor (int i=0; i<users.Count; i++) {
6 s3 U% m9 S& Z2 x! X content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?
$ s! p4 [& `+ l8 R users.SelectSingleNode("login_name").InnerText : "") + "</td>"; $ e* y* k6 X, b' p2 {) f V4 x
, s9 H( j4 n$ ^% \) B, m5 h& V6 i content += "<td>" + ((users.SelectSingleNode("first_name") != null) ?
6 u4 q' O4 e) }: ]1 V+ F# j) g users.SelectSingleNode("first_name").InnerText : "") + "</td>";
; q ^: m4 }% c! ~& a 2 |1 w. _1 @5 N5 k# p/ `+ j
content += "<td>" + ((users.SelectSingleNode("last_name") != null) ?
0 ~" c' Z" e! H0 u! S7 _. _6 x& w users.SelectSingleNode("last_name").InnerText : "") + "</td>"; * V; _ { A+ e) x( O4 v! B$ e
! f1 N0 f- D0 a% q8 K* k content += "<td>" + ((users.SelectSingleNode("email") != null) ?
) y S; v8 I) f$ |6 s3 ?# b users.SelectSingleNode("email").InnerText : "") + "</td></tr>"; & b9 }% [9 A% C& R3 s: V
2 w6 }9 w" `/ D4 a6 b
}
8 K# @7 X0 C" k" n1 I % C' ~6 D) D2 v) m1 P' r X
content += "" +
5 W, ?5 }# X& c" u! V. l: g "</tbody>" +
& n' m/ I! c: H! G4 q& U* T "</table>";
9 Z: _5 Z6 @2 F% S5 p a4 {1 q6 } ) u6 ]4 q( E( S$ ]: t
return myInnovator.newResult(content); / x6 h3 o1 i& d8 N# d
/ Q) H6 y& o2 ]' y- F% o
|
|