|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
; w' o. o4 o; d' ^
" k- T3 K4 r/ k% S0 ?
9 C4 P% f$ d; t% J" @Technique ; C0 S0 O$ A w7 g9 a
Use the Innovator.applySQL( … ) method to submit SQL direct to the database. This " b3 Q$ A2 y$ Y" q
recipe returns the XML from the applySQL() method and forms HTML for a table to
& r+ A0 s( u; p0 m3 Ydisplay the data.
2 H' V% b) ^3 `. L( n- H) k. o& Y2 `) j3 D4 i" R
6 r! A, R2 R. t4 J3 m: \
C#
' u# r$ }& j9 eInnovator myInnovator = this.newInnovator(); 9 q a" j, L$ I2 F
Item results = myInnovator.applySQL( 8 r! b) y6 J! t0 q4 u6 Q
"select login_name,first_name,last_name,email " + ; u% ^ c; Y* A( V
"from [user] " + ( w* E1 \! H" d! {; E7 j
"order by last_name,first_name");
5 L4 x$ l# P4 b) p9 m - W* F# k- g+ A
string content = "" + 2 B6 A% B) b" C9 c' K0 h5 o x
"<style type='text/css'>" +
& T3 Z( s6 V) a/ Q- V "table {background:#000000;}" +
5 R2 x+ u a$ R "th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" +
Q8 Q. ^1 L3 C' Q5 n: g "td {font:normal 10pt Verdana; background:#FFFFFF;}" + 9 x I% `. F4 f9 x& E8 C
"caption {font:bold 14pt Verdana; text-align:left;}" + 2 V5 ]: m$ Y8 L/ U
"</style>" +
* C5 N% |* s# \; O0 x% Q( A c D "<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
) P8 C2 {: d. g& E$ l* j2 N! F "<caption>User Directory</caption>" +
/ S E( z/ D7 r3 e3 k7 | "<thead>" + & v4 [$ `& `2 }8 v2 S, t P
"<tr>" +
; m8 f; o# W, `# Q "<th>Login Name</th>" + / Q Q. X1 P' q& o. K
"<th>First Name</th>" + + w, [! s' V1 }& F8 u
"<th>Last Name</th>" + 7 N: b9 R2 I* g4 Z& j' r
"<th>EMail</th>" +
9 y$ V0 W+ L) }8 ?% h1 B: J9 r$ E "</tr>" +
: J" @: t7 d9 a5 v7 h" ]& u9 [ "</thead>" + 5 N2 P# g" e3 r* v. C
"<tbody>";
5 D6 i$ K. \$ r- v+ E: }1 e ) a% }8 {9 h2 ?+ X
XmlNodeList users = results.dom.SelectNodes("//recordset/row"); 3 c( B& I% B' l! p, f. \
for (int i=0; i<users.Count; i++) {
' ?( Q, z1 j; ? content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?
! x' _1 J7 P! B( V: l& K users.SelectSingleNode("login_name").InnerText : "") + "</td>";
: S# D$ ]+ j4 n" e6 o! ] + b9 d K) B4 t* x
content += "<td>" + ((users.SelectSingleNode("first_name") != null) ? 8 D1 K) ], X/ G# H9 i
users.SelectSingleNode("first_name").InnerText : "") + "</td>";
T) v N# @) V$ {6 l3 |. D
$ `- m8 a7 N$ g7 C) C content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? . K* @) w q# N$ I4 p! |
users.SelectSingleNode("last_name").InnerText : "") + "</td>"; 9 N- @1 l3 W4 \- F7 n0 F
& {$ `8 \9 |* M! P: u content += "<td>" + ((users.SelectSingleNode("email") != null) ?
2 ^' _( x2 T+ \ users.SelectSingleNode("email").InnerText : "") + "</td></tr>"; 6 y! T! W4 Y8 F6 L# E3 W
6 i1 K3 [1 Z; |; @6 L
} , W' C% v% L, W$ `0 ^+ o" D3 b
1 u* d8 D8 `- f3 J" ~* e. P1 {content += "" + ' H1 O8 R5 ]! b- h9 N
"</tbody>" + # e: k1 A: _9 e- L8 H/ f0 d
"</table>";
& v$ x5 m/ R) Q4 a
+ L) M0 P. j7 X8 u$ \. h8 creturn myInnovator.newResult(content); , I, z. E3 C1 u) D9 a3 ~2 D3 _
' E4 a2 g* D& p, t4 r& V- \) |( r
|
|