1

I'm using WATIR and Ruby 1.9.3 to test web applications and I need to connect to Microsoft SQL Server Management Studio 2008 (Windows 7 64-bit). I already installed "DBI and DBD-ODBC" gems. I have also installed the ODBC Data Source, which I named 'BUILD'. I was following the next steps, but unfortunately I'm getting a syntax error message. This is what I tried:

require 'dbi'
conn = DBI.connect('DBI:ODBC:BUILD', 'username', 'password')conn.connected?

Which gives me this error message:

SyntaxError: (irb):2: syntax error, unexpected tIDENTIFIER, expecting $end
...'username', 'password')conn.connected?
...                           ^
    from C:/Ruby193/bin/irb:12:in `<main>'

I honestly don't know what I'm doing wrong. I searched online for a solution, but apparently I couldn't find any answer that it can help me. I'll appreciate your help thanks!

2
  • What's going on with "conn" before ".connected?" ? Commented Apr 27, 2012 at 20:01
  • I edited the question - I hope the missing (?) newline in line 2+3 was not the problem. Commented Apr 27, 2012 at 20:04

2 Answers 2

1

For easy access to a SQL Server you should have a look at TinyTds https://github.com/rails-sqlserver/tiny_tds

Sign up to request clarification or add additional context in comments.

Comments

1

I think you have a syntax error in this part:

conn = DBI.connect('DBI:ODBC:BUILD', 'username', 'password')conn.connected?

Try running this instead:

conn = DBI.connect('DBI:ODBC:BUILD', 'username', 'password') #==> sets up the connection

conn.connected?  #==>  true if it is working

You had a method call followed immediately by a variable which is why your compiler is complaining that you never ended the method before you called conn again.

1 Comment

This sounds like a totally different issue. If you are still struggling with it you should open up a new thread. To get you started I would check out railsforum.com/viewtopic.php?id=37103 .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.