|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
7 P7 e5 @" ^3 @ U( F
! N/ K' T' D2 Y* j6 h2 @! M) t
7 `; z" Y+ P s8 T" T4 u4 e. MTechnique
7 w2 j4 d2 I& E( N IUse the Innovator.applySQL( … ) method to submit SQL direct to the database. This
: f: Y1 {& ~! f- V, I; K. H2 Hrecipe returns the XML from the applySQL() method and forms HTML for a table to ! M+ o7 ~/ v j8 {/ C1 i) _# c( u
display the data. ; k3 g# s: g+ x+ `$ Y7 K$ A
. c, a% U8 Q0 g9 n2 d P
4 b8 F2 b, }+ d" k$ UC# 1 ~( |4 e0 u$ t" u
Innovator myInnovator = this.newInnovator();
j5 `$ d/ K/ ]6 a; cItem results = myInnovator.applySQL(
7 e- d9 R3 o: L "select login_name,first_name,last_name,email " +
Z, o- T( C6 X2 W- f! z* L "from [user] " +
9 @, b: G: M2 M. w* }3 U "order by last_name,first_name"); / j: |9 N" D1 U' o
/ _8 X9 ~) N- N% S# s: Fstring content = "" +
3 s# }- a5 Y) g4 D2 h "<style type='text/css'>" +
3 [) N5 o& H5 k- r! v "table {background:#000000;}" +
$ c8 _" s8 Y! v1 ?$ w "th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + , Q3 a1 N& z% q$ l9 K
"td {font:normal 10pt Verdana; background:#FFFFFF;}" + % m/ f3 {8 ~6 O& h$ y$ l
"caption {font:bold 14pt Verdana; text-align:left;}" +
9 v8 _2 |! `, i "</style>" +
: T4 G0 e* S3 j5 [) E& o "<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
' r" W3 A( P; D! g* `+ T" Y "<caption>User Directory</caption>" + 6 @# E3 A& q. M5 `( {
"<thead>" + 3 ^3 y: y9 N( Q' U4 W0 a' p
"<tr>" +
' x, C1 N/ i1 l1 |3 q) R @! J "<th>Login Name</th>" +
* }. K. L+ v9 y3 _. ~ "<th>First Name</th>" + 3 U2 a+ f- U. B
"<th>Last Name</th>" + . V- |7 P" s+ k, X/ j
"<th>EMail</th>" + T4 e' l; S$ b/ _7 B5 _2 L
"</tr>" +
1 x( ?) _$ Q, Q S1 ^ "</thead>" +
" N; K+ M9 o+ K5 g8 q% y* ? J "<tbody>"; 0 ~. h' Q4 U0 W/ E$ l
5 e; r; q) h9 M* eXmlNodeList users = results.dom.SelectNodes("//recordset/row");
E1 t: Z' `4 a- M6 F8 qfor (int i=0; i<users.Count; i++) {
9 b/ z2 {" L- { content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?
+ C( m1 e$ X, c* y, Q0 ?2 V# v users.SelectSingleNode("login_name").InnerText : "") + "</td>";
/ Z0 V' z+ F! q# G: c+ a6 N9 u; { / { @( {! ^+ e$ I- \& N, `2 h4 x
content += "<td>" + ((users.SelectSingleNode("first_name") != null) ? 0 X% m( G- E" h3 B
users.SelectSingleNode("first_name").InnerText : "") + "</td>";
- U3 H4 h3 a1 a" B) o8 p: ?
) [% e5 w( h0 c content += "<td>" + ((users.SelectSingleNode("last_name") != null) ?
" |6 p8 s, l; j$ g6 Z users.SelectSingleNode("last_name").InnerText : "") + "</td>";
4 [6 n6 o) ^2 p8 p- o" @; H J5 W
" o+ N& D, c- f( B) O, T, a$ P content += "<td>" + ((users.SelectSingleNode("email") != null) ?
* j; {9 b# P6 S/ ]3 M. L5 y) | users.SelectSingleNode("email").InnerText : "") + "</td></tr>"; 7 k1 ~3 u1 d# d( s
. m4 { J8 @5 }4 a) t} , J; e2 C& Q9 d$ k
7 v E$ c! e% c8 c4 U; M9 s. e3 _content += "" +
, w7 p) D: T8 o4 M: U "</tbody>" +
0 p S3 o$ i8 r- n "</table>";
- q7 j0 `( w( a# V* P8 |2 l0 F ! a; I8 l6 B2 [7 O9 k
return myInnovator.newResult(content);
4 o" q ^& m: O6 n j2 x3 S% x4 T( W4 D3 [* b, ~; b+ a
|
|