数据库是ms sql2000,有张数据库表a,
字段如下:
a b
1 数学
2 语文
ruby代码:
require "dbi"
dbh=DBI.connect('DBI:ADO:Provider=SQLOLEDB;Connect Timeout=5;DataSource=localhost;Initial Catalog=cs;Persist SecurityInfo=True;User ID=sa;Password=sa;')
sth=dbh.prepare("select * from a ")
sth.execute
while row=sth.fetch do
p row
end
显示的结果会:
ruby db.rb
["1 ", "\312\375\321\247 "]
["2 ", "\323\357\316\304 "]
Exit code: 0
怎么都变成数字了。
[b]问题补充:[/b]
那怎么让他转成中文?我在SciTE测试的,就要利用上面的代码。
此数字是汉字unicode的表示。