易截截图软件、单文件、免安装、纯绿色、仅160KB

ruby 连接操作 sql2005


The following is improved version of the code created by David Mullet, from
http://rubyonwindows.blogspot.com/2007/03/ruby-ado-and-sqlserver.html
require 'win32ole'
class SqlServer
# This class manages database connection and queries
attr_accessor :connection, :data, :fields
attr_writer :username, :password
def initialize(host, username = 'sa', password='')
@connection = nil
@data = nil
@host = host
@username = username
@password = password
end
def open(database)
# Open ADO connection to the SQL Server database
connection_string = "Provider=SQLOLEDB.1;"
connection_string << "Persist Security Info=False;"
connection_string << "User ID=#{@username};"
connection_string << "password=#{@password};"
connection_string << "Initial Catalog=#{database};"
connection_string << "Data Source=#{@host};"
connection_string << "Network Library=dbmssocn"
@connection = WIN32OLE.new('ADODB.Connection')
@connection.Open(connection_string)
end
def query(sql)
# Create an instance of an ADO Recordset
recordset = WIN32OLE.new('ADODB.Recordset')
# Open the recordset, using an SQL statement and the
# existing ADO connection
recordset.Open(sql, @connection)
# Create and populate an array of field names
@fields = []
recordset.Fields.each do |field|
@fields << field.Name
end
begin
# Move to the first record/row, if any exist
recordset.MoveFirst
# Grab all records
@data = recordset.GetRows
rescue
@data = []
end
recordset.Close
# An ADO Recordset's GetRows method returns an array
# of columns, so we'll use the transpose method to
# convert it to an array of rows
@data = @dat


相关文档:

如何将 Access 数据库转换到 SQL Server

http://support.microsoft.com/default.aspx/kb/237980/zh-cn
将 Access 数据库转换为 SQL Server 的最简便方法是使用升迁向导。升迁向导:
保留数据库结构,包括数据、索引和默认设置。
自动将 Access 有效性规则和默认设置转换为适当的 SQL Server 等效内容。
在升迁后保持表关系和参照完整性。
要在 Access 2000 ......

SQL Server 2000 数据库同步

文章来源:http://blog.sina.com.cn/s/blog_537ca30d0100bvja.html
为什么要同步SQL Server 2000 数据库,它都用在什么场合
数据实时备份同步,数据库服务器出问题时我们也有其正常工作时的备份
数据实时备份同步,一台服务器负载不起时,可以用来做负载均衡
数据实时备份同步,数据库服务器可以无间断,无损失迁移 ......

sql嵌套查询

select * from sq_donglong.achi_news where ID in (select ID from (select top 6 ID from sq_donglong.achi_news where SortID=82)a union all select ID from (select top 6 ID from sq_donglong.achi_news where SortID=84)b)
......

在XP上安装SQL 2000 Server(摘转)

今天从网络上找到了在XP上安装SQL 2000 Server的方法,此前我一直认为这是行不通的,后面google一查,还真是可以,有很多网站都说这个方法可行,我就让lp试试看,结果真行,转载一下吧: 在Windows XP上安装SQL Server 2000的主要流程为:
一、在SQL服务器的安装盘中找到MSDE这个目录,并且点击setup.exe安装它,过程 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号