VBS使用recordset对象增删查改
上一篇 /
下一篇 2014-05-11 13:49:49
/ 个人分类:VBScript
E {&CYi(T.j0set con =CreateObject("ADODB.connection")
1l4D-D
]I~%p(L0set rs=createobject("ADODB.recordset")51Testing软件测试网!e5n7{
u2Q'Y
strsql=“select * from tablename”51Testing软件测试网 Z(x4eCIO
u'`T
con.ConnectionString="此处略去30字……"
Tm
\/y(S;?"S0con.open51Testing软件测试网!]vJqH4m'Q
?P^2[6f'n(x0查询
8p'Op)_D:_f1|W0rs.open strsql,con,1,2
4PQzP4]^yI0if not (rs.bof or rs.eof) then51Testing软件测试网]7c[|N2Rf%O#l;\{
strname=rs("name")51Testing软件测试网(l0a;ny-p|k
A
=rs.feilds("name")
s*Ewb/Z\r}0end if51Testing软件测试网2D7|!C(V#?qq
51Testing软件测试网/o
B,cV]P7R&pgetrow:将数据集保存到二维数组
Df9Eys0strdata=rs.getrow(2,0)51Testing软件测试网 ^h6Or{
'从第一行开始复制两行到二维数组
!?,?
iSr{0str(1,0)第二咧第一行51Testing软件测试网GSGHH
`]U,b2v
strdata(1,1)第二列第二行
*L_w#o
sii(E
ds0getstring:将数据集作为字符串返回51Testing软件测试网*cY*~4nW.G
51Testing软件测试网.J:n(eJ{$PF
筛选51Testing软件测试网xEhE8rfZ
rs.filter="name='json'"51Testing软件测试网 q.ax%UkTz
R:hJ"~Eb7Kz~0新增
oIf)J#os,o051Testing软件测试网Q?.P;O\*G7e
rs.addnew51Testing软件测试网!x-q,l~"G
rs("name")="张三"51Testing软件测试网+RN5BB9i,wonRZT
rs.update