|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
3 a% K$ g% o, U% `1 w( L/ ~
3 z' m! ~% }: \- ~
0 A6 x, D, x+ k+ wTechnique 2 h, F( g$ p. H
Use the Innovator.applySQL( … ) method to submit SQL direct to the database. This ) W. X7 M. i2 r: \0 i! _
recipe returns the XML from the applySQL() method and forms HTML for a table to & N$ Y: F& e3 q$ @ Q# q
display the data.
7 @. ]' y( {7 f2 e
/ G5 B+ I' l# H7 y+ ]3 A* m. n
7 @, o! C' S( y( W1 n; BC# / t4 Y7 t3 w* S5 B( J1 \; D
Innovator myInnovator = this.newInnovator(); " @# I" h9 _- y2 B
Item results = myInnovator.applySQL(
5 G1 e, v+ u6 {8 ]8 e2 A "select login_name,first_name,last_name,email " +
' O& v2 k+ d1 p5 A "from [user] " +
2 T8 U# E& ?3 i$ y "order by last_name,first_name"); # Q1 E: J( Q: C) B
/ {8 T2 R. L% n' n
string content = "" +
7 W* |3 t# f$ ]5 q3 U "<style type='text/css'>" + ; @( @0 _! V3 v
"table {background:#000000;}" + % Y4 s$ G* D5 o
"th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + ( k' J0 l" O. O+ |
"td {font:normal 10pt Verdana; background:#FFFFFF;}" +
I- F+ J9 J0 h4 u! N "caption {font:bold 14pt Verdana; text-align:left;}" +
* j, A' d+ s, ?( H3 n& u# W "</style>" +
T/ |5 D* ^. K( t "<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
( ^: E/ s* c; i "<caption>User Directory</caption>" +
1 D- V7 x% @* ~, u7 L) ?/ L5 d; ^% A "<thead>" + & x# a! }( t+ b$ {- S( J2 r
"<tr>" + 2 l( Z. e. P2 I
"<th>Login Name</th>" +
+ Y ~3 ?9 r6 [# r. A: j "<th>First Name</th>" + ; A* ]) ^$ A' A) X
"<th>Last Name</th>" + 7 x% ~0 A* `: |. l" T& R
"<th>EMail</th>" +
" U. W: a8 K! N& I "</tr>" + ) d! t, w9 r) l P+ @) d
"</thead>" +
- J3 a, k- K$ P6 [0 `3 E& u "<tbody>"; q8 j# J& r& [, I5 p! o1 @
' p( }' I: Z# C
XmlNodeList users = results.dom.SelectNodes("//recordset/row"); i: \/ {2 s, G* W
for (int i=0; i<users.Count; i++) { + g9 D" `% @5 I; V0 \) l6 e
content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ? ' t8 X* y* _4 y6 Q
users.SelectSingleNode("login_name").InnerText : "") + "</td>"; : k8 {6 G4 T$ e, ^& i3 w! t* r+ q
! d( |" F2 [( h content += "<td>" + ((users.SelectSingleNode("first_name") != null) ? / M& R) H: L1 M9 h& G! ]7 \" O) q
users.SelectSingleNode("first_name").InnerText : "") + "</td>";
" N) Q N" b, \7 P) ^! s+ g 4 ^$ n8 P3 x' t- h; \# f
content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? ( k% g, |/ U ^* W( C# w: q8 S2 F
users.SelectSingleNode("last_name").InnerText : "") + "</td>";
; p' @$ G+ w0 ^# C2 \$ Y
8 M% t+ s/ Q5 u' P/ I content += "<td>" + ((users.SelectSingleNode("email") != null) ? 5 h( x, |, U5 r! f l) P
users.SelectSingleNode("email").InnerText : "") + "</td></tr>"; # K8 n& m$ \- _, ?5 O/ \# f+ y
% \5 m/ u: V* q% o" `7 Q
} ! y& C/ G& J1 Z5 o5 H' X8 M
7 j( B/ P% T7 `) s* ]4 o
content += "" +
7 d6 x0 [. h7 f" N- k "</tbody>" +
% q* Y: _! q3 a% `: G9 P "</table>"; $ z( E0 T7 Y, i! {" x! Q* a
6 o9 ~+ N0 \) j* k* {
return myInnovator.newResult(content); 1 b, q2 p0 v: r5 @# n
1 ?" m/ G; } P% q' V, x& Q9 v |
|