|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 }& J$ F% S. z2 v
' ]* d+ s7 t/ x; g
8 s* L) ]8 ?7 G; T
Technique 5 d0 |- b8 s% B3 B s: `
Use the Innovator.applySQL( … ) method to submit SQL direct to the database. This
7 V N2 U' H- B+ ^. y& A3 Lrecipe returns the XML from the applySQL() method and forms HTML for a table to
9 j4 g- R: a' x% D* Hdisplay the data.
- g O7 r' U$ P( L5 i F5 U1 |9 t7 A" N' V
* B6 {# G0 X4 h! P& v
C#
: b, Z% } _' s5 e: `1 mInnovator myInnovator = this.newInnovator(); 1 L8 M' h, u9 K7 Z
Item results = myInnovator.applySQL(
: K: ?" C; B! a8 `* s$ n q "select login_name,first_name,last_name,email " + 8 F8 S% h# {# K. |' Z, X
"from [user] " +
2 K8 A! L: E. [. g* q "order by last_name,first_name"); 5 S' D7 b. v- z" \& `4 F
# ~. m9 `# C' Y1 M' J) j: e% f% Qstring content = "" +
; y. p( n3 F" T2 Y "<style type='text/css'>" +
$ p/ s7 l+ R2 I4 m( O "table {background:#000000;}" +
, Z8 E$ D8 \4 J* s' o "th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + + }- c U' ]+ K9 y' M3 ]) v
"td {font:normal 10pt Verdana; background:#FFFFFF;}" + 0 v& j4 M: m4 H' H `
"caption {font:bold 14pt Verdana; text-align:left;}" + 2 a& H3 C& B* t: B# Z/ X
"</style>" + 0 o6 l) L/ ~" _0 u- y# q; C! } W
"<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
* w; W2 o9 h7 f$ C8 I "<caption>User Directory</caption>" +
' y A: E7 `5 e6 I "<thead>" + 7 n. a$ M+ r* w) K
"<tr>" + ; R9 z0 B: N2 `3 R: [) m. S+ `
"<th>Login Name</th>" + " c4 i: Q3 I5 R
"<th>First Name</th>" +
/ t' t7 J* B& U& c& }( x+ V2 l "<th>Last Name</th>" + ( q# n* P/ o( L) x
"<th>EMail</th>" +
) ]/ f) K2 F8 v' n/ a "</tr>" +
/ L. L! C: V: C "</thead>" +
6 Z- f5 D" A1 Z" I "<tbody>";
2 j5 c5 W+ p! l6 w: u9 G1 Y# [ : l! g2 \+ H+ F: V' t9 G6 p
XmlNodeList users = results.dom.SelectNodes("//recordset/row"); 1 M( w8 \. H0 S+ c; `* g
for (int i=0; i<users.Count; i++) { / y) o4 y/ g* P$ o3 g8 N
content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?
/ A# ?' \" a, u4 d users.SelectSingleNode("login_name").InnerText : "") + "</td>"; 2 M9 X/ Q3 t4 a: p$ w2 [
9 J9 c" H6 R0 L! n7 K, p$ f9 N% m content += "<td>" + ((users.SelectSingleNode("first_name") != null) ? ) i6 s+ _% d# @
users.SelectSingleNode("first_name").InnerText : "") + "</td>"; ' `3 N; y6 q) G& X/ f8 G4 A! a0 q1 P
9 z, A* c, S5 Z content += "<td>" + ((users.SelectSingleNode("last_name") != null) ?
8 ` a1 s1 S9 \1 `/ n/ { users.SelectSingleNode("last_name").InnerText : "") + "</td>"; 6 W- h: {, b$ k% q' w
b+ `0 S) p1 f content += "<td>" + ((users.SelectSingleNode("email") != null) ? ) } b/ j1 I+ W
users.SelectSingleNode("email").InnerText : "") + "</td></tr>";
5 R0 r) K+ m) g$ P9 I! w7 L
' t" X( J4 X6 z} ' M; N4 b8 y" g) `/ J
@( p) s; p$ ?0 W3 g
content += "" +
* \: h$ t0 C3 r5 ^7 O/ e "</tbody>" +
7 W% W0 i& b7 @+ N "</table>"; ; [$ I- G6 O4 h4 B* Y
- C; J6 q4 b1 r3 @' @. k- y
return myInnovator.newResult(content);
7 X, P' R5 l6 r! H. N9 R+ K4 h
: Q8 m( Z5 Y: \6 a+ ~( L |
|