a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 153|回复: 1

[Access] 2012年计算机二级ACCESS的参数化查询(5)

[复制链接]
发表于 2012-7-31 22:26:35 | 显示全部楼层 |阅读模式
string Sql   {
3 |9 B, [4 G+ H+ ]' O  [0 X  get, ?1 ?! I$ X8 |2 y
  {5 ?) |: ^# n* r# \
6 u  v  F8 f/ p6 q
  return sql;. [$ q2 t/ s4 `& z- i
  }
) A+ k3 W2 N7 o& |  set! n" R/ s8 c4 v
  {
. o2 i* c( e: n+ A% Y* G8 S  sql = value;
: }* h; y7 j( M0 v- p0 K. U  }' o, i: l0 N- g7 w& n. y8 d
  }3 S( }) T, e5 j0 s
  int T) N; x( I( d; S) T" O3 Y9 s4 U
  {
- j% v  w* j# G  get- S9 `* t( M0 x; X/ S# |' F; p2 b
  {: X' _3 {  `  T" P; g& A7 {# u
  return t;
' k! ?/ ]" z# r' S& c- R( s9 G  }
) x1 \  h4 f( ]1 W1 ~; |8 b  set
! l( G. D4 w  ]  {
) n( e% s# [6 U/ b2 t" b8 \$ {  t = value;6 @. W  T9 e( g$ h# x4 Q: R3 v* W
  }
5 n: {/ I& _& ]" _1 J+ D6 Y" J  }
7 t" Y! n  X9 ^# ^5 V3 [  object V' {0 S0 W  e% a  T& Z! _
  {
" @" r1 a1 N+ U  get; I0 U# _# d( K
  {
8 _. S4 [, S+ r; K  _! G! K  return v;
4 y3 ~8 P1 k; D$ y4 R" @" n  }3 _" r, K) W8 ^9 O. g, n! W3 f
  set: A! g3 g) \- G5 J
  {
* O& D. Q! L3 ?  v = value;- ~3 M- u7 L* B: e& n2 y0 M; a
  }( ?% E1 w' {/ J% W7 s* G. c
  }
) s- o! E; e5 n, M1 x4 O  }
8 c  H7 R% S, {' j1 [9 H( D0 g# l
% g; v/ D% e8 d/ E* Q  }
回复

使用道具 举报

 楼主| 发表于 2012-7-31 22:26:36 | 显示全部楼层

2012年计算机二级ACCESS的参数化查询(5)

</p>  //调用方法9 g0 x- m/ w9 T. w" E+ d' E
  //accselect acc = new accselect();$ Z, Z) R% \2 D+ O! l' S
  //acc.sql = "select * from dtt where d_id=?";
' l5 H- `; ?/ L8 ~5 w+ }  y  //acc.t = 10;& D; [/ q$ c- d% }
  //acc.v = 1;
, v3 |2 F% w+ I: P! v! }% {  //OleDbDataReader oda = acc.getOdd(OleDbType.VarChar);
$ C3 U9 U( B8 m0 D9 M  //Repeater1.DataSource = oda;
. m* w) A- S0 e  |  //Repeater1.DataBind();
8 A% a0 `; E) I% Z  function acc_sql(sql,adotype,adodct,strlong,values)( s7 q  H( g8 `) U' i. Y1 H! }( ~
  dim connstring,mycmd,myrs,conn% l. _2 d; h7 I# G  l
  connString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("db1.mdb")3 a3 n& J' m$ i  }8 A; s
  set conn = Server.CreateObject("Adodb.Connection")
" G" G, r# S' _  conn.ConnectionString = connString+ Y% J0 D0 n, ^5 N9 o
  conn.open()  \* Z  F& t1 p+ e) k' A
  set mycmd = Server.CreateObject("ADODB.Command")
9 q( n4 x3 E" @# [  mycmd.ActiveConnection=conn
8 m) r) H: w* l  mycmd.CommandText=sql/ s' f0 |+ f+ W9 g, P4 D! I6 V/ \
  mycmd.Prepared = true+ p: j) i8 W# c% B1 |# Z
  set mypar = mycmd.CreateParameter("temp",adotype,adodct,strlong,values)+ |# {* d! h/ Z6 ]; D4 [4 X& Z
  mycmd.Parameters.Append mypar
- X! S! ^$ v3 r% m+ b% x  set myrs = mycmd.Execute
! t' W* T, Y7 t9 z' \( B9 x  set acc_sql=myrs
1 X4 B" ?& b  ~# k  end function
& G8 O; x* g/ ?, S& V  ’调用方法2 U4 J) T/ _3 w2 n# P
  ’dim rs
5 D! g2 m3 D0 M) X% r  ’sql="select * from users where id=? order by id"
  q" S" s* o& X  ’set rs=acc_sql(sql,3,1,4,1)
' g9 t! o) |" L: @1 u  ’if not rs.eof then9 E/ a7 q' G$ L
  ’response.Write(rs(1))' z6 d* z: m5 u  Z
  ’end if
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-5-6 04:33 , Processed in 0.254658 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表