Skip to content

Platform Installation Windows

metaskills edited this page Sep 13, 2010 · 19 revisions

Windows MS ODBC Problems?

If you are finding that your column data (national varchar, text, decimal, etc) is coming back as binary or the data is truncated with “\000\000” or “\000”? The solution – when setting up your ODBC Datasource (DSN) in odbcad32.exe make sure that:

“Perform translation for character data” is OFF. “Use regional settings when outputting currency, numbers, dates and times” is OFF.

Thanks to @adamdennis for this.

Ruby 1.9.1 on Rails 2.3.5 on Windows XP
[currently under test / March 2010]

Before installing activerecord-sqlserver-adapter you have to install the ruby-odbc gem
But beware ! It needs a C – compiler for installation.
Either you have a ten year old Microsoft MSVC++ 6.0 Compiler
or better you may install the Ruby Development Kit first.

So step by step:

  1. Install devkit
  2. gem install ruby-odbc
  3. gem install activerecord-sqlserver-adapter
  4. Maybe install
    Microsoft SQL Server 2005 Native Client
    Microsoft SQL Server 2008 Native Client
  5. Create a ODBC Data Source
  6. Modify database.yml
    development:
    adapter: sqlserver
    database: MyDatabase
    dsn: dsn_MyDatabase
    mode: odbc
    username: TestUser
    password: xxxxx
    encoding: utf8
  7. Create an activemodel
    class Customer < ActiveRecord::Base
    set_table_name “dbo.Customer”
    set_primary_key “CustomerID”
    end
  8. Create an activecontroller
    class CustomerController < ApplicationController
    def index
    @customers = Customer.find(:all, :conditions => [“CustName LIKE ‘Klaus%’”])
    respond_to do |format|
    format.html
    end
    end
    end
  9. StartRails: ruby script\server

and voilá : I get the error message : “failed to allocate memory”
ok, stay tuned I will do my best to find the failure cause

Update: the problem comes from a ntext column in my table …