|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
+ _ O, i& g5 E$ T3 ?3 P& {' Y4 d/ l- z* B9 f* p" {
: \4 j( A5 f% M+ yTechnique , f2 f! a$ x% Q: v
Use the Innovator.applySQL( … ) method to submit SQL direct to the database. This 8 F" q& p5 ~7 T7 Q/ P
recipe returns the XML from the applySQL() method and forms HTML for a table to
0 W! _. h& d% V; q3 odisplay the data. $ l" m3 f o# v+ j- ^
$ H) t6 K0 R! x% d* j
e- }. O, y6 L9 n3 Z" C! q
C# + g% \9 C7 q( d; M
Innovator myInnovator = this.newInnovator();
( Z& t) h: ~9 D4 N9 jItem results = myInnovator.applySQL( ( X( l! ~0 y& m+ ]# A
"select login_name,first_name,last_name,email " +
, ]: K. ]5 X: w6 v. o "from [user] " +
. i! ^& z! ]/ R; t; G% p "order by last_name,first_name"); 5 ~; M' f+ G" I& A. ~2 f5 M
8 D' S( w( ]' Z
string content = "" + : [2 y1 U2 ]1 _9 F: y
"<style type='text/css'>" +
5 f- S& m% |9 v "table {background:#000000;}" + ) c3 t% f8 F6 W# q: E1 Y
"th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + $ V- b7 x* m1 N4 j2 E' I! ]" X" H) z
"td {font:normal 10pt Verdana; background:#FFFFFF;}" +
' P5 N- s" n+ x' g8 ~ "caption {font:bold 14pt Verdana; text-align:left;}" + 8 s2 E& P1 t( O. [( K
"</style>" + % D% l, f' P _0 k4 A
"<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" + . M- r, [) n0 |% }& `& k) u
"<caption>User Directory</caption>" + * u9 E! M+ w3 a
"<thead>" +
k. |; S3 B2 t7 }; t8 t; h" R "<tr>" + % e& ?; S/ [$ k3 I
"<th>Login Name</th>" + ! c4 h0 g) F# d
"<th>First Name</th>" +
/ Y& }# w& _. b0 Y "<th>Last Name</th>" + $ Z+ m" k0 a8 C8 ^
"<th>EMail</th>" +
6 o2 W4 D2 c3 _ d "</tr>" + ' n3 X, z5 e/ i3 {
"</thead>" + " z- P5 u: H" F1 Y6 n& A3 P
"<tbody>";
5 e# [1 C% x" e, j) |
i& |' P- u( N. i& \: LXmlNodeList users = results.dom.SelectNodes("//recordset/row"); ! l+ X" W$ h( E/ o! N
for (int i=0; i<users.Count; i++) { " v1 k1 w6 S0 O: Z& O
content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?
& a5 j6 S. H7 ~2 N! U! c, X3 _ users.SelectSingleNode("login_name").InnerText : "") + "</td>";
! W7 s. K4 n8 t3 h + _0 r; S' b9 N" K
content += "<td>" + ((users.SelectSingleNode("first_name") != null) ?
c q- @) a" @3 f" `/ s users.SelectSingleNode("first_name").InnerText : "") + "</td>";
5 M5 H, g4 y* C + C T0 y' ?7 [8 y* l5 y) p, V# z
content += "<td>" + ((users.SelectSingleNode("last_name") != null) ?
: _: D: j- n! r' J+ h users.SelectSingleNode("last_name").InnerText : "") + "</td>"; ' Y5 ]' a+ ?2 }; z. a4 u
+ y a( _; F2 X% e content += "<td>" + ((users.SelectSingleNode("email") != null) ?
/ ]# U) `5 P: F1 i users.SelectSingleNode("email").InnerText : "") + "</td></tr>";
2 g$ E/ I- F4 _# F' @, g0 h 9 {2 h' A9 |+ G. ], s/ A1 p3 ]
} , ]1 h" h. ^% H
" @: s. b, s- Z u! vcontent += "" +
: Z; Y8 e( I* Q+ ]* Y; v3 z "</tbody>" +
/ D3 Q4 Q0 W: `# P. Y "</table>"; . `1 a, v6 a$ g: |; q) J
( T w* |3 e+ \2 E* P; h& ]; Q( \
return myInnovator.newResult(content); ! v4 b9 b6 o+ W$ i( V
0 J0 J4 V/ W: @7 A0 e: _0 ] |
|