易截截图软件、单文件、免安装、纯绿色、仅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 ......

在XML里写SQL语句(把SQL语句写进XML里)

你知道XML文件吧?(不知道的GOOGLE去!)那你听说过在XML里书写SQL语句吗?换句话说,把你的项目里所有SQL语句存储在XML文件里,你听说过吗?你做过吗?
我头次听说是小艾告诉我的,我敢肯定他是个这方面的高手,呵呵(赞一个,到此为止!)
那给你展示一下,在XML里书写SQL语句吧
<commands>
  <comman ......

java中使用jdbc连接sql server 2005

准备工作
首先,操作系统中安装好SQL Server 2000/2005,如果系统中都装有2000和2005版,记得停用一个,只开一个行了。
然后,到微软网站下载Microsoft SQL Server 2005 JDBC Driver 1.1
,也可以使用这个地址直接下载

解压sqljdbc_1.1.1501.101_chs.exe,把sqljdbc_1.1复制到%ProgramFiles%(如果系统在C盘则为C:\ ......

mysql创建数据库sql实例

mysql创建数据库sql实例
# MySQL-Front 3.2  (Build 2.10)
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET CHARACTER SET 'latin1' ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号