Connectivity Code

Hi.

I am connecting from Console to SQL Server with ruby on rails on windows
XP
but while executing the following code, only the coloured code is
executing,
i want the exact procedure, how to connect from database step by step
procedure…

require “dbi”

begin

connect to the SQL server

dbh = DBI.connect(“DBI:ODBC:TESTDB:localhost”,
“testuser”, “test123”)

get server version string and display it

row = dbh.select_one(“SELECT VERSION()”)
puts "Server version: " + row[0]
rescue DBI::DatabaseError => e
puts “An error occurred”
puts “Error code: #{e.err}”
puts “Error message: #{e.errstr}”
ensure

disconnect from server

dbh.disconnect if dbh
end

An error occurred
Error code:
Error Message:IM002(0)[Microsoft][ODBC Driver Manager]
data source name not found and no default driver specified

On Wed, Feb 2, 2011 at 8:04 PM, Peter H. <

It would be useful if you posted the error messages.

Well it would seem to be a configuration problem with SQL Server and
not the ruby code as such.

My SQL Server experience is out of date but the error message seems to
be coming from the ODBC driver so I would guess that the dbi package
is working ok. Do you actually have a database called “TESTDB” and is
it available on localhost.

Are there any other tools you could plug the connection string into (I
seem to recall something like SQLQuery, a gui for making quick queries
on the database). Does the other tool connect using the same
connection string?