V
Vani Kulkarni
Hello all,
I have been to trying to connect to SQL Server 2005 from ruby code.
Following is the code written:
------------------------------------------------------------------------------
require 'dbi'
driver = 'ODBC'
server = "PRODSK0322"
database = 'TestDB'
user = 'sa'
password = 'Sa123'
connection_string = "DBI:ODBC
river={SQL
Server};Server=#{server};Database=#{database};Uid=#{user};Pwd=#{password}"
begin
# connect
db = DBI.connect(connection_string, user, password)
# get data and print
row = db.select_one("SELECT TrnEmployees")
puts "result: " + row[0].to_s
rescue DBI:
atabaseError => e
puts "Error #{e.errstr}"
ensure
# disconnect from server
db.disconnect if db
end
------------------------------------------------------------------------------
I am getting an error saying :
"Error IM002 (0) [Microsoft][ODBC Driver Manager] Data source name not
found and no default driver specified"
Can any one tell me where I am going wrong?
Is there anything I need to install or am I missing anything in includes
or requires?
Thanks,
Vani
I have been to trying to connect to SQL Server 2005 from ruby code.
Following is the code written:
------------------------------------------------------------------------------
require 'dbi'
driver = 'ODBC'
server = "PRODSK0322"
database = 'TestDB'
user = 'sa'
password = 'Sa123'
connection_string = "DBI:ODBC
Server};Server=#{server};Database=#{database};Uid=#{user};Pwd=#{password}"
begin
# connect
db = DBI.connect(connection_string, user, password)
# get data and print
row = db.select_one("SELECT TrnEmployees")
puts "result: " + row[0].to_s
rescue DBI:
puts "Error #{e.errstr}"
ensure
# disconnect from server
db.disconnect if db
end
------------------------------------------------------------------------------
I am getting an error saying :
"Error IM002 (0) [Microsoft][ODBC Driver Manager] Data source name not
found and no default driver specified"
Can any one tell me where I am going wrong?
Is there anything I need to install or am I missing anything in includes
or requires?
Thanks,
Vani