Class | ActiveRecord::ConnectionAdapters::SQLServerAdapter
In: | lib/active_record/connection_adapters/sqlserver_adapter.rb
Parent: | AbstractAdapter

In ADO mode, this adapter will ONLY work on Windows systems, since it relies on Win32OLE, which, to my knowledge, is only available on Windows.

This mode also relies on the ADO support in the DBI module. If you are using the one-click installer of Ruby, then you already have DBI installed, but the ADO module is NOT installed. You will need to get the latest source distribution of Ruby-DBI from ruby-dbi.sourceforge.net/ unzip it, and copy the file `src/lib/dbd_ado/ADO.rb` to `X:/Ruby/lib/ruby/site_ruby/1.8/DBD/ADO/ADO.rb` (you will more than likely need to create the ADO directory). Once you‘ve installed that file, you are ready to go.

In ODBC mode, the adapter requires the ODBC support in the DBI module which requires the Ruby ODBC module. Ruby ODBC 0.996 was used in development and testing, and it is available at www.ch-werner.de/rubyodbc/

Options:

- `:mode` — ADO or ODBC. Defaults to ADO.
- `:username` — Defaults to sa.
- `:password` — Defaults to empty string.

ADO specific options:

- `:host` — Defaults to localhost.
- `:database` — The name of the database. No default, must be provided.

ODBC specific options:

- `:dsn` — Defaults to nothing.

ADO code tested on Windows 2000 and higher systems, running ruby 1.8.2 (2004-07-29) [i386-mswin32], and SQL Server 2000 SP3.

ODBC code tested on a Fedora Core 4 system, running FreeTDS 0.63, unixODBC 2.2.11, Ruby ODBC 0.996, Ruby DBI 0.0.23 and Ruby 1.8.2. [Linux strongmad 2.6.11-1.1369_FC4 1 Thu Jun 2 22:55:56 EDT 2005 i686 i686 i386 GNU/Linux]

### Methods

active? adapter_name add_column add_limit_offset! begin_db_transaction columns commit_db_transaction create_database current_database delete disconnect! drop_database execute indexes insert native_database_types new quote quote_column_name quote_string reconnect! recreate_database remove_check_constraints remove_column remove_default_constraint remove_index rename_column rename_table rollback_db_transaction tables update

### Public Class methods

new(connection, logger, connection_options=nil)

### Public Instance methods

active?()

Returns true if the connection is active.

adapter_name()
add_column(table_name, column_name, type, options = {})

Adds a new column to the named table. See TableDefinition#column for details of the options you can use.

add_limit_offset!(sql, options)
begin_db_transaction()
columns(table_name, name = nil)
commit_db_transaction()
create_database(name)
current_database()
delete(sql, name = nil)

Alias for update

disconnect!()

Disconnects from the database

drop_database(name)
execute(sql, name = nil) {|handle| ...}
indexes(table_name, name = nil)
insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
native_database_types()
quote(value, column = nil)
quote_column_name(name)
quote_string(string)
reconnect!()

Reconnects to the database, returns false if no connection could be made.

recreate_database(name)
remove_check_constraints(table_name, column_name)
remove_column(table_name, column_name)
remove_default_constraint(table_name, column_name)
remove_index(table_name, options = {})
rename_column(table, column, new_column_name)
rename_table(name, new_name)
rollback_db_transaction()
tables(name = nil)
update(sql, name = nil)

[Validate]