|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
( m; b+ Q- [. v7 p6 `; w5 W1 i0 }. b
9 Z. t, M4 k0 K7 z0 l! o% s% f
2 \" Z6 X, Q; ?3 }
Technique
2 h* y4 v$ p9 c' J' G, UUse the Innovator.applySQL( … ) method to submit SQL direct to the database. This
3 G8 B3 ^ z* J% Arecipe returns the XML from the applySQL() method and forms HTML for a table to 7 j4 E- P3 x# m) Q5 `
display the data. 3 k" D9 w8 g8 I6 R/ ?1 v9 Q
1 B5 L& u4 i/ w9 c7 E- r' h h3 L1 ~9 e/ e: N0 p9 S3 j) \/ n; C
C#
+ L5 g$ D% z% \Innovator myInnovator = this.newInnovator(); " Z1 E$ O8 j, m+ E* z' [/ k2 a
Item results = myInnovator.applySQL(
+ q- Z# N) T. h2 D% K "select login_name,first_name,last_name,email " +
8 e) A; [& o8 n* a9 K1 L/ X; b$ ~( D "from [user] " + $ K9 Z. C, t4 n3 h& K% p _0 o
"order by last_name,first_name"); 2 U7 m: z! }# ~/ f) O
( [' C, k5 |7 v# ?
string content = "" + 8 M- n8 C2 W% ^" k2 \, J: v6 H( h
"<style type='text/css'>" +
8 ^) h1 K! D' i8 a3 Q "table {background:#000000;}" +
, e; f {* \& x) h0 {' m "th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" +
% z$ \" A9 @& F$ h! Z "td {font:normal 10pt Verdana; background:#FFFFFF;}" +
8 A! B. S: g7 _$ m S+ s0 z7 ?) n "caption {font:bold 14pt Verdana; text-align:left;}" + M* w* ^& E; Z
"</style>" + 0 t5 h1 ?8 ]( F7 \! h( `, x
"<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
4 u% P" o: w4 M "<caption>User Directory</caption>" + 5 S6 U) v9 R: _- ?, H0 O
"<thead>" + ) _/ u, y! V9 j3 ?, k8 I; M
"<tr>" +
: A" [' Y7 z3 R0 {. s/ l "<th>Login Name</th>" + # V; F4 W$ w3 M. l
"<th>First Name</th>" + * O( }/ D, v5 p+ I
"<th>Last Name</th>" + 5 [0 D3 a. x9 N/ |1 b" {4 `
"<th>EMail</th>" + 9 q1 y Y. q$ @# G
"</tr>" +
! C& c" b2 J' U6 G, v0 N: C "</thead>" + 9 f0 l/ S& G6 o' q0 M% A
"<tbody>"; 1 g2 e$ z: N" I! E' p7 t
* f( ?. W% {- V4 F
XmlNodeList users = results.dom.SelectNodes("//recordset/row");
1 A; D- g$ A. D jfor (int i=0; i<users.Count; i++) {
& k8 w6 ^7 V, w8 D: z$ Y3 B, { content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ? / G: E( r+ e ], d8 e: v
users.SelectSingleNode("login_name").InnerText : "") + "</td>"; & K( x$ k/ ?: }; y% C+ [0 {
6 I" k' C+ \5 M1 h content += "<td>" + ((users.SelectSingleNode("first_name") != null) ?
% M" E3 E( j; [9 N" f6 L' _1 M% k- v users.SelectSingleNode("first_name").InnerText : "") + "</td>";
. ~# l! }4 N. c: Z" F& P; j0 o 4 f5 }1 ~. C; s1 F' ^* c! t
content += "<td>" + ((users.SelectSingleNode("last_name") != null) ?
. h3 q# b. R: m5 b! G0 Y# L users.SelectSingleNode("last_name").InnerText : "") + "</td>"; ' x1 G/ z0 r: f
+ L, q; H( _6 {9 O4 b- P' a& X content += "<td>" + ((users.SelectSingleNode("email") != null) ?
1 `6 {8 B% _. z! T users.SelectSingleNode("email").InnerText : "") + "</td></tr>";
1 E% h- \, @) G
* p; J/ b$ p p4 O2 k, g; m}
8 @; x$ @/ `2 D ]0 ?- a. U
1 y" B( o2 M; u. L9 hcontent += "" +
( G/ m U2 \7 f "</tbody>" +
" I% m8 r' V% W; p "</table>";
( K H. Y" B/ e 0 D( l" Y" ^- ~1 O6 }" e5 n& e& W
return myInnovator.newResult(content); 2 E _' X7 j+ ~. ?* [ K
2 F+ T$ z' O6 {- w% v9 y
|
|