|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
j" C: u5 v. A
6 j* I; w( n* v- b$ ]( }/ H, W+ }, S( h5 E7 E- Q" k6 l
Technique
0 x* b3 j o8 Y8 {7 p& F1 {Use the Innovator.applySQL( … ) method to submit SQL direct to the database. This
) c, }; B/ y- u9 m9 J5 jrecipe returns the XML from the applySQL() method and forms HTML for a table to
! W1 L3 w5 ]2 P: I' i5 Idisplay the data. + Y/ S0 c3 a0 ?2 G) k( c: |
" U) b- w- b# [4 A
! j) Q4 I$ j7 E. V# h3 `4 LC#
2 a. Y2 S( X# iInnovator myInnovator = this.newInnovator(); , r& T* e3 b [
Item results = myInnovator.applySQL(
) g R; {. j# K "select login_name,first_name,last_name,email " +
& Q0 v, Q0 W1 N% ~# w% W "from [user] " + 9 U) z+ f2 G+ L) w+ H- x4 c
"order by last_name,first_name");
) V( P4 z( G8 \1 f - Y4 ^, e% Q( |6 f' m: V6 {" @1 O
string content = "" + 2 Y1 e+ `9 I/ {) H6 m; }
"<style type='text/css'>" + " W; f4 X8 h5 u4 D( A
"table {background:#000000;}" +
+ Y5 I; N+ d0 Y4 {# l "th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + + r1 v" ?5 ]1 ] M" R
"td {font:normal 10pt Verdana; background:#FFFFFF;}" +
2 S# J+ v' t3 C1 {8 @* D "caption {font:bold 14pt Verdana; text-align:left;}" +
6 _7 V5 p: b7 Q; y2 U1 I) M! }7 v% d "</style>" +
( |/ \2 w9 T, [7 u "<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
) m* e% Q' x5 _% _! c/ H "<caption>User Directory</caption>" +
, C7 x# a( J- I7 s "<thead>" +
% j' h: E* A, W5 [! Z, Z$ Z "<tr>" +
& H" d* J2 R4 Q: Y9 U4 P "<th>Login Name</th>" +
$ p0 w; k c" k x- q p "<th>First Name</th>" +
6 r3 U% O, `$ v, T" L5 \3 c F "<th>Last Name</th>" +
/ H# P& i! F, T0 \5 j "<th>EMail</th>" +
/ l2 K% S3 R* \( S4 D "</tr>" +
B4 m5 G; O8 P "</thead>" +
. j1 }" y7 Y/ ^: j' Y/ \1 z7 M4 K "<tbody>"; 8 ?- }" m6 {( U; [' Y2 |7 {* {
' o+ b3 Z8 E- E$ \
XmlNodeList users = results.dom.SelectNodes("//recordset/row"); 8 ?. R% H; f& ~# v4 r0 }
for (int i=0; i<users.Count; i++) {
8 C% P4 l) i2 D2 D' F" D/ } content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?
" L4 A# ~8 D! w) r( z4 z0 | users.SelectSingleNode("login_name").InnerText : "") + "</td>"; - m) J: y" }% L& ?- b
! l0 C# |7 N" T7 a4 H& t' W
content += "<td>" + ((users.SelectSingleNode("first_name") != null) ?
! S8 X! c, h, z2 Z2 b a7 g users.SelectSingleNode("first_name").InnerText : "") + "</td>"; 2 B" J' _" B2 o0 D, }- ^1 \
+ G# Y! v4 G6 V5 a7 a* [
content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? ) T& J' ~3 u P! h1 a
users.SelectSingleNode("last_name").InnerText : "") + "</td>"; 5 t' z0 l: a) h, G O
@" {$ Q6 P+ s( N6 r! J" z: F7 z content += "<td>" + ((users.SelectSingleNode("email") != null) ?
' i2 E& d2 ^$ [( f/ e, c+ L! H0 K! ? users.SelectSingleNode("email").InnerText : "") + "</td></tr>"; 0 N$ Y- M- T# O) J4 [2 M. F1 _( ]
4 L% Z& H: U6 f! K: f7 X% N! V}
/ i; p" \* L; D, u7 |# V; J 2 h }/ {4 c1 k6 e) p
content += "" + 6 y/ p9 _9 q; k8 {1 C+ G6 f
"</tbody>" + ; V1 J. {8 `4 x+ O
"</table>";
& [7 I5 v a; c4 d
3 e0 L9 J# \* u/ oreturn myInnovator.newResult(content);
6 l H8 `' c- U3 U3 E& }; G2 P
& B9 H, ~; g9 k |
|