|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
6 w" S0 H- l% {+ o4 e
2 H7 F/ {" j7 {, x$ n7 M/ |. L. M; h' n8 p( [$ Z+ c' B9 \7 I# h
Technique ( n4 w" r/ L {9 G. r
Use the Innovator.applySQL( … ) method to submit SQL direct to the database. This 8 F/ R% @& ~, Z3 B
recipe returns the XML from the applySQL() method and forms HTML for a table to
& a5 p- e" d! A" ^( tdisplay the data.
9 B: P4 Y3 @% x" t
4 m' {6 ?! ~( `2 S* ^0 z0 p# O& ^1 E# p. D0 \" t. _* C9 G2 l( l
C# 2 I# |9 Z$ @9 X- P' `$ c% ^
Innovator myInnovator = this.newInnovator();
7 k) n8 d% j' h. G% h/ bItem results = myInnovator.applySQL(
/ i) |( Y* e, @8 Q "select login_name,first_name,last_name,email " + 9 F1 e' Y, x7 }! Y. w8 {
"from [user] " + ! K o, b5 e; y0 Q. w# |
"order by last_name,first_name"); # c# h) E' d3 T9 q
5 n% r! ~5 o' Ystring content = "" + 3 s6 O R# h2 L8 j' D+ O
"<style type='text/css'>" + ! i" k/ _$ r7 J0 x$ z& }5 I
"table {background:#000000;}" +
4 ~" _! M% p9 l" w! \* h8 y; U2 _! F "th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" +
1 ]% R" |4 I6 Q4 V2 Q "td {font:normal 10pt Verdana; background:#FFFFFF;}" +
- C) w9 M+ i6 I8 y/ @" \ "caption {font:bold 14pt Verdana; text-align:left;}" +
( g$ p7 B8 ?. a8 g0 _% h. g "</style>" +
3 [0 B1 z5 i1 \; k. X k& a5 ]+ e "<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" + ( _4 e8 V6 U5 |! _8 L7 `
"<caption>User Directory</caption>" + r5 U3 z8 J: N5 e( ^; Z
"<thead>" +
0 k$ o$ o5 w. a1 u+ F7 d "<tr>" + 0 A4 ]5 i( d( S# M
"<th>Login Name</th>" + 0 S0 A+ ^% y. o- g
"<th>First Name</th>" + 1 z6 @8 z3 g' l, I! Q( g
"<th>Last Name</th>" + + W; B g0 @; R" d& U, y X! a# v
"<th>EMail</th>" + ; I2 ^, E: L# j4 C* C+ G
"</tr>" +
. c, n+ `+ D [; K' p "</thead>" + 3 x* h9 c' E2 g* b& N2 o( N) Y# ?
"<tbody>"; / h* e" M6 s5 f# \- a% t, ]
9 K4 \' t" n* P8 `( |1 a9 u( G
XmlNodeList users = results.dom.SelectNodes("//recordset/row");
, O% |1 q9 ^& @7 h4 o d7 R3 w+ jfor (int i=0; i<users.Count; i++) {
3 Z: e0 P4 X/ l& R* K content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?
( @. Z- A. p* A# F users.SelectSingleNode("login_name").InnerText : "") + "</td>";
4 }" O" V7 b/ n s6 d4 m
* e" K. u, k3 j' D+ h content += "<td>" + ((users.SelectSingleNode("first_name") != null) ? - g& N6 q# E; Z! G8 w
users.SelectSingleNode("first_name").InnerText : "") + "</td>";
, n' ?( H2 b1 N2 g
$ x0 A* V" C f! ]. I: z7 T content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? + L% q# O- K& {8 q0 Q j% I
users.SelectSingleNode("last_name").InnerText : "") + "</td>"; 1 \* M9 I4 ?: F5 }$ L
4 X! \, i/ M4 e; R9 s1 U
content += "<td>" + ((users.SelectSingleNode("email") != null) ?
$ a) f% ]0 j7 | a! r, O users.SelectSingleNode("email").InnerText : "") + "</td></tr>"; 7 r1 L/ H, }5 v7 X
+ d! r0 F8 _6 }2 O' a( S: m: Z} ; i9 n$ q1 \2 S- v( V. @1 Z3 p
5 I3 u7 [; ^- E; s$ acontent += "" + 5 k5 b! h# T @
"</tbody>" + 8 ?; v* G" o+ D# Y# p6 |
"</table>"; 4 H. S7 V1 a, f3 s1 E, f1 L
D" O0 W* Z+ B* {; z/ A( }
return myInnovator.newResult(content);
2 k {2 _ |, H1 t" w* `! i( V) W
/ U; W& [ Y3 n& S' u |
|