|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% {8 b* f* ?) \8 a3 r8 \: q* n7 L! _$ h1 ^2 k8 ^8 f( f
7 t$ f( P( w3 `5 {$ m( v( J
Technique
! V, a' G' E4 N7 ] ~# hUse the Innovator.applySQL( … ) method to submit SQL direct to the database. This $ P- {1 d( R" ?
recipe returns the XML from the applySQL() method and forms HTML for a table to ' o3 p+ n* [+ m
display the data.
. O' Q! D$ C1 f2 ]0 C3 ]5 d- Y
" X7 i! O0 A2 ~' b* { Z& Z% J1 U. P
C#
9 B* S6 O- ~ F5 m3 YInnovator myInnovator = this.newInnovator();
5 K1 B6 j! g% y( R( C0 u5 Q5 RItem results = myInnovator.applySQL( 0 Z9 a% q8 V, z
"select login_name,first_name,last_name,email " + ! O5 I& \2 C/ K
"from [user] " + . L, \" I, F6 f# G `" I+ y
"order by last_name,first_name");
" s9 E$ W. R B % p' n, j; e5 I, v
string content = "" + ; i' `6 R( V( H& c; r/ g, e* U
"<style type='text/css'>" +
& D7 B5 i( E9 ]& e "table {background:#000000;}" + C1 `* q+ D# k
"th {font:bold 10pt Verdana; background:#0000FF; color:#FFFFFF;}" + & {6 _" g& z. x( b
"td {font:normal 10pt Verdana; background:#FFFFFF;}" +
* O( ?& @( j, z) o3 N/ k "caption {font:bold 14pt Verdana; text-align:left;}" + 5 @8 |$ F6 I1 \7 @ S9 S; d1 D. \
"</style>" + 8 `$ c' i/ l# I/ g2 C. F% p( t0 ~
"<table id='tbl' border='0' cellspacing='1' cellpadding='2' datasrc='#itemData'>" +
3 E, I. v& f% \" f) k7 m "<caption>User Directory</caption>" +
/ l( n3 e, x' | ]' d2 j "<thead>" +
" w. G; z" E) ~9 c2 h) Y "<tr>" +
/ M0 P. k! c6 V& s "<th>Login Name</th>" + / t+ ~" h, `' `0 [2 T' f+ _# O
"<th>First Name</th>" +
% s8 o7 N: n+ c8 H$ ] "<th>Last Name</th>" +
8 C( k% D1 c$ N$ Z1 D "<th>EMail</th>" +
! c4 }9 G7 K6 J "</tr>" + 2 n- P; S4 v: x; \
"</thead>" + - A7 Z3 s$ d7 t5 w
"<tbody>";
% D/ ~( Z) {" T* a ! Y4 J$ r1 D( X, C5 V' T; |
XmlNodeList users = results.dom.SelectNodes("//recordset/row"); ) s- p5 Y C& m
for (int i=0; i<users.Count; i++) {
; p- t( @1 d3 b: { content += "<tr><td>" + ((users.SelectSingleNode("login_name") != null) ?
' v2 b: h" L2 t5 b5 ^; ] users.SelectSingleNode("login_name").InnerText : "") + "</td>"; - W! j& e+ p) M' Q
4 S+ O+ h; i; f content += "<td>" + ((users.SelectSingleNode("first_name") != null) ?
" ]5 E3 ~7 _2 { users.SelectSingleNode("first_name").InnerText : "") + "</td>"; , l! v. t! ~( A3 ^% F
q Z! e$ H2 K. K
content += "<td>" + ((users.SelectSingleNode("last_name") != null) ? ( S& x& [7 e. O( W) i, L9 e
users.SelectSingleNode("last_name").InnerText : "") + "</td>"; * F" X& \; ^* o# f) t, j
! Q0 @1 U) H( N* ?7 @ content += "<td>" + ((users.SelectSingleNode("email") != null) ?
+ v, m7 R( C( f$ x users.SelectSingleNode("email").InnerText : "") + "</td></tr>"; 6 e: T2 C4 t. N1 `+ E
! _9 D& |1 ? ]) [( P* y( ?( j
} ; q$ `6 Q" d/ }; C6 X9 w+ T
9 K' i2 s! A7 V) d& m8 jcontent += "" +
2 @9 U7 J1 H! X6 L+ R( A- V "</tbody>" +
, C+ O7 S4 Q% ^3 s1 u1 l6 l' o "</table>"; ) ?/ q4 H5 X2 A( O0 A3 H
+ Q! H) f9 n& N( `return myInnovator.newResult(content); ( _: D; b8 m6 ?. H- B: ~$ Y, k
& @! Y2 m! c" `: D- j) U9 p I4 O
|
|