[Ironruby-core] Ironruby on Rails with SQL Azure

Ameer Deen lists at ruby-forum.com
Wed Sep 1 09:44:16 EDT 2010


Hi there Orion,

Firstly, thanks very much for the prompt reply! I tried using IronRuby 
to query against my local sql server and SQL Azure. I'm a Ruby noob but 
I've listed below what I used.

I'm able to query against both SQL servers and obtain the time and 
servername using Transact-SQL. As mentioned earlier, however, I was 
unable to use rails to connect to SQL Azure.

The SQL Azure credential I've listed below is real and can be used for 
testing.

Any other ideas?

test script:
-----------
require 'mscorlib'
require 'System.Data, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089'

include System::Data::SqlClient

#connection = 
SqlConnection.new('Server=.;Database=dev;Uid=myuser;Pwd=MyP at ssw0rd')
connection = 
SqlConnection.new('Server=nrvk7uv6tl.database.windows.net;Database=cloudoman;Uid=myuser;Pwd=MyP at ssw0rd')
connection.open

command = SqlCommand.new("SELECT getdate() as my_date, @@SERVERNAME AS 
my_name",connection)

my_reader = command.execute_reader()
my_reader.each do |x|
  puts "Server Name: #{x['my_name'].to_s}"
  puts "Time: #{x['my_date'].to_s}"
end

my_reader.close
connection.close



Orion Edwards wrote:
> My guess is that SQL Azure doesn't follow quite the same protocol as 
> normal
> SQL Server. As I don't have a SQL azure account, I can't play around 
> with it
> myself, but I'd suggest trying to get a simple command line version of
> IronRuby up and running and see if you can use the raw sqlserver adapter 
> to
> connect to SQL azure at all?


-- 
Posted via http://www.ruby-forum.com/.


More information about the Ironruby-core mailing list