测试之家淘宝店:主营软件测试定制服务
http://shop71136398.taobao.com/
软件评测试考试论坛:http://www.testdao.com/forum-113-1.html
2012软件评测师考试群:28388329
watir连接SQL Server2005
上一篇 /
下一篇 2009-08-18 11:29:33
/ 个人分类:watir+ruby
a) http://rubyforge.org/projects/ruby-dbi/下载dbi-0.2.2.zip
+A'o5f6~ q.Nmy0 51Testing软件测试网!e]$KF0H9A
b)解压缩到某目录,然后到该目录下执行2条cmd命令51Testing软件测试网l1~O5r+L}me7zH
51Testing软件测试网ib9bP2U3iQ
ruby setup.rb config
|:r{8A5C5M6W
PY*T0 ruby setup.rb install51Testing软件测试网c_+s|:Mz4Y
51Testing软件测试网$T`B5S"q
c)从lib\dbd复制ADO.rb到ruby的安装目录<Drive>:\<Ruby Dir>\lib\ruby\site_ruby\1.8\DBD\ADO ADO文件夹要自己建51Testing软件测试网$xc)_M'us$h
6GK#B,o;UP0d )测试代码:
wZ.X[H ?Y0 51Testing软件测试网i-s+F#y(vCNR^!m
require "dbi"51Testing软件测试网cE]aV H1X
dbh=DBI.connect("DBI:ADO:Provider=SQLOLEDB;Connect Timeout=5;Data Source=192.168.1.252;Initial Catalog=Leggat;User ID=autodata;Password=autodatapassword")51Testing软件测试网&]Z-W~__Z
sth=dbh.prepare("select username from dbo.LeggatSaler")
4w@?E7~$vO$a@4w0sth.execute
h.D/Mq_6b|X0while row=sth.fetch do
3OGdQ^0~#g
j0p row
)K#z t(qBg7ky0end
$H'tac,m5\0
"b7?9h#U `1n0e)运行,就能看到LeggatSaler表中的数据被读出来了51Testing软件测试网\+_ZX3X#d%{ho M
51Testing软件测试网:W
Ys2MT7o:d/g
收藏
举报
TAG: