' s5 J8 }) n% o9 a C
, |# X1 ~, l0 V, e: [+ Z( w2 G
例子1写入方法一:0 e- R# [- C1 d7 J( y& G
A) }8 d# ^7 D z- x" P9 x<%
" O' u2 C; }7 y. z Lset rst=server.CreateObject("Adodb.Recordset")
% e* K+ P( w7 ~, B9 Srst.open "select * from uid where i_uid='" & request.form("i_uid")& "'",conn,1,1
5 ]& N9 d& g5 h' u0 H2 ]
if rst.recordcount>0 then
5 Q* w, t1 @/ V e& v* nresponse.write ("Sorry,已经注册过了")
/ @$ t: x) E4 M, Z+ O; C4 L1 u% E$ S
response.end
4 }1 b+ s3 Z8 M- ], m( W# i) }
else
( U9 b5 ]! o" I; t" ?set rst1=conn.execute("insert into uid (i_uid,i_code) values('"&request.form("i_uid")&"','"&request.form("i_code")&"')")
+ B }; h1 \4 O2 E- V! Y8 w
set rst2=conn.execute("insert into user (u_name,u_sex,u_age) values('"&request.form("u_name")&"','"&request.form("u_sex")&"','"&request.form("u_age")&"')")
: z' ]: E- x' i0 E n5 d
end if
- Y4 L ^" n6 o. {* i+ i, t%>
/ o* i+ ?% b$ j. o
& p5 t0 ]/ \* j* U( k例子2 写入方法二:: i1 ]% J" O2 q3 {9 g7 A1 T
# x7 F6 v5 }/ I( L% d) C( F6 C
) ? W( F" j! f: B<%
. R# O& Y, r( F& _set rst=server.CreateObject("Adodb.Recordset")
! I9 d3 t$ m- Hrst.open "select * from uid where i_uid='" & request.form("i_uid")& "'",conn,1,1
) o( t/ Q; s/ Z* r$ `! c- N8 U
if rst.recordcount>0 then
- O, K# E6 S7 n4 g `response.write ("Sorry,已经注册过了")
3 t9 G8 {% \" j% n; P2 |rst.close
8 p3 b$ Z3 }5 z' A0 yset rst=nothing
& @4 M0 w8 i4 t; p3 J3 u# I
conn.close
5 s+ l0 a! r, D7 I3 v0 C( ?
set conn=nothing
& Q% M+ R1 W6 \
, q* G1 b# }+ ~! Y Z: Hresponse.end
, d' X( `" T3 [else
4 H4 a! R* u8 J+ k6 h0 ^2 X0 {% m
rst.close
l( U1 h" }( B! S4 N$ C6 Z5 K N% j! c) O
rst.open "uid",conn,1,3
( r, H; J1 n7 |% d5 h! l7 ~3 `* g
rst.addnew
- o3 D2 W* Y, l$ G- m/ m& l- M# ^# V% T
rst("i_uid")=request.Form("i_uid")
5 K5 E' v8 i: I! {rst("i_code")=request.Form("i_code")
k, W' e* g; N3 \rst.update
; W6 s/ C5 x0 r7 Orst.close
9 N o7 _# \5 z9 ~8 l- N8 J G* W6 N) V6 i1 o$ k; h
set rst1=conn.execute("SELECT @@IDENTITY as i_id1")
1 u9 v7 K1 P9 n3 u1 P/ W' Ji_id1=rst1("i_id1")
) ?0 y. a. T! N" F# |8 Y
rst.open "user",conn,1,3
, j1 C& ]2 x/ N! ~; w
rst.addnew
. g; b$ a* r$ z9 Q# j" |
rst("u_id2")=i_id1
2 ]+ `8 X; \9 g7 `8 d2 Z* G. wrst("u_name")=request.Form("u_name")
) | l, Z/ t( P8 ~
rst("u_sex")=request.Form("u_sex")
% s/ I/ [. L4 x2 ` c5 x
rst("u_age")=request.Form("u_age")
) P/ ^$ A7 Q# orst.update
# e; R: R: U5 \9 r" Hrst.close
4 j) m4 T1 e) k% w9 q: \end if
" A8 \/ U! H0 e# l%>
( G/ y/ X6 E# L3 F0 j. a7 j
-----------------------------------------------------
! g% ~* `5 q! r8 Q: @; z' J
# y! j+ x: k8 C/ @2 z
释放代码:
0 p$ [( h: @+ X$ p- V7 O<%
0 F% c6 k3 Y2 p, b$ n, [set rst=nothing
1 z. M/ @6 l1 t2 Q6 C' aconn.close
7 \2 O3 O" U: dset conn=nothing
' T m. H) x# V9 G%>