|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
" m1 B7 M \$ u! c$ r
# a' s% U4 I( D) A
" F& l0 [" V$ U3 Q' p/ W
Technique
0 P! R+ t- W" qUse the Innovator.applySQL( … ) method to submit SQL direct to the database. This # P' i% i2 i; R9 @
recipe returns the XML from the applySQL() method and forms HTML for a table to * j# f1 w+ ? x( n
display the data.
. k2 j0 b- C$ z5 _0 c3 `: r
" |: K3 E$ R V1 |) f) s* {
2 c1 |3 g/ V7 nC#
% F. l; |+ r8 X0 T$ F. X- S' P/ wInnovator myInnovator = this.newInnovator();
2 D9 ~5 v, S# ]Item results = myInnovator.applySQL( 7 |" x+ }! o& c2 U; m6 T
"select login_name,first_name,last_name,email " + ; }5 |! Q9 Y" G' U
"from [user] " +
$ e( o' B' C. S- w0 y8 h$ Z "order by last_name,first_name");
i- s& C* x* v B: a
; u+ ], t5 U7 o! kstring content = "" + . N0 N9 y- e) P& E9 O- L* q
"<style type='text/css'>" + : c4 k! J" h0 v* X( }; x7 @
"table {background:#000000;}" + % {6 _! A2 i2 z! [; L( j3 V% Y
"th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" +
% T) ]1 T8 _2 j& p! @4 Q& L3 ^ "td {font:normal 10pt Verdana; background:#FFFFFF;}" + 9 [ q7 ?) Y( E6 g( h. n* a
"caption {font:bold 14pt Verdana; text-align:left;}" +
+ k: u9 \+ D2 A2 y0 k% I* [ "</style>" + - e5 y8 _5 H2 r# X
"<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" + , {' }$ u' b7 d
"<caption>User Directory</caption>" + $ D: d* q: N) P3 f; j$ h
"<thead>" + }% S* E! i, _7 Q# M2 T' K
"<tr>" +
3 {6 T' A5 U, h8 G "<th>Login Name</th>" + , h7 w* a. x, B0 @6 q O- H9 Y
"<th>First Name</th>" + 5 Y: z1 o+ V- \7 K/ J& s
"<th>Last Name</th>" +
, w/ Y! a1 S$ I: D' u! A "<th>EMail</th>" + 4 f$ F8 i6 t9 S+ j( K* \7 r! B! q
"</tr>" + 6 x4 {- D; Y: ]' l x, z8 `& `
"</thead>" + 6 a- z3 ~ R' D
"<tbody>";
7 N; M% t# L7 C- \8 q: M" |" |) g 7 K! [# C/ q2 b, m
XmlNodeList users = results.dom.SelectNodes("//recordset/row"); . t3 T0 o: W, ~
for (int i=0; i<users.Count; i++) {
2 J Z$ o, X# T: p content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ? 1 e- v0 r1 ~# j+ W
users.SelectSingleNode("login_name").InnerText : "") + "</td>"; + ]5 C' `5 E" }
G( ?8 z. w& w9 U0 b content += "<td>" + ((users.SelectSingleNode("first_name") != null) ?
' U( @& F, W' w: F users.SelectSingleNode("first_name").InnerText : "") + "</td>"; 6 ]2 B, Q% Y( T0 P( N
2 d U+ X2 G( J
content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? 2 Y4 n0 h+ k0 |6 ^
users.SelectSingleNode("last_name").InnerText : "") + "</td>";
. ?& J* y$ x9 A2 D7 e# d @# M) Y) ]
% X+ l$ A- Q* f" Y9 r8 z m* n content += "<td>" + ((users.SelectSingleNode("email") != null) ?
2 A' r) z' ~; D9 }' B. m users.SelectSingleNode("email").InnerText : "") + "</td></tr>";
! V7 |0 P( v) [1 i ]' m( {+ r+ a 2 B8 |, w' `3 x, `$ {
} ! |7 C9 [ E( h; e
4 ]6 y# u+ x4 f8 Ucontent += "" + + L- I0 T& L+ D! f/ S9 m
"</tbody>" + 4 R4 f* _- i1 Q' b3 z _- G
"</table>"; , z, R1 X: z! p, b" L& g: H ?7 M
' ~2 |7 N, L3 y+ b. ~$ q# C* Ereturn myInnovator.newResult(content);
t3 o3 ^1 g3 ?5 G% f0 q% ]+ H) h* ~6 c
|
|