SapphireSteel Forum
Welcome, Guest. Please login or register.
May 22, 2013, 09:27:42 AM

Login with username, password and session length
Search:     Advanced search
Welcome to the SapphireSteel forum - for discussion of the Ruby In Steel and Amethyst IDEs
3884 Posts in 800 Topics by 669 Members
Latest Member: m
* Home Help Search Login Register
+  SapphireSteel Forum
|-+  General
| |-+  Ruby In Steel
| | |-+  Problem creating rails app with SQL Server backend
« previous next »
Pages: [1] 2 Print
Author Topic: Problem creating rails app with SQL Server backend  (Read 3382 times)
corix
Newbie
*
Posts: 11


« on: February 02, 2012, 12:11:06 AM »

Hello,

I am trying out Ruby in Steel for the first time and while installation went fine on my virtual windows xp, creating rails app with SQL Server database didn't. I am receiving the following error:
     Database creation failed
     SQL Server database creation failed: Changed database context to 'master'.
     Creating testdb_development
     Msg 50000, Level 16, State 127, Server VIRTUALXP\SQLEXPRESS, Line 42

I followed the tutorial about installation and creating rails app using SQL Server. Except I use SQL Server authentication instead of windows authentication. Any help will be greatly appreciated.

Thanks,
Corix
Logged
Huw Collingbourne
Administrator
Hero Member
*****
Posts: 934



« Reply #1 on: February 02, 2012, 04:30:54 AM »

What happens when you click the Test Connection button in the Ruby In Steel Rails wizard?

Also, have you updated either Rails or SQL Server recently? We've had two queries about SQL Server in the past few weeks and I don't think we've ever had anyone reporting similar problems before. Since there have been no changes to Ruby In Steel in that time, I wonder if there may have been changes to either SQL Server or Rails?

best wishes

Huw
Logged
Huw Collingbourne
Administrator
Hero Member
*****
Posts: 934



« Reply #2 on: February 02, 2012, 04:36:01 AM »

Also look here: http://groups.google.com/group/rails-sqlserver-adapter/browse_thread/thread/727324833212acb7?pli=1

If you don't have the SQLServer adapter installed probably the easiest way to make sure you have all the bits you need is to do a full install of Rails and Ruby using this: http://railsinstaller.org/
Logged
corix
Newbie
*
Posts: 11


« Reply #3 on: February 02, 2012, 09:24:54 AM »

Hi Huw,

Thank you for the quick response. When I click Test Connection it says "successful".

Before I even install Ruby in Steel, I already have SQL Server 2008 R2 Express installed and I have Ruby on Rails installed via RailsInstaller 2.0.0. Using this setup, I was able create rails app with SQL Server manually using ODBC and DSN connection. I have tried tiny_tds before but no luck.

To install Ruby In Steel, I decided to uninstall Ruby on Rails and just do a fresh installation of everything as described in your tutorial:
     - Visual Studio 2010 Shell (updated to SP1)
     - Ruby 1.9.2p290
     - DevKit tdm 32-4.5.2-201112291559-sfx
     - Rails 3.2.1
     - Ruby In Steel 2
     - gem install tiny_tds
     - gem install activerecord-sqlserver-adapter
     - copied ado.rb from dbi-0.2.2 file I downloaded from http://rubyforge.org/frs/?group_id=234&release_id=20222 because I can't find it on your site to the folder \site_ruby\1.8\DBD\ADO (there is no 1.8 folder so I created one)
     - I also copied the file to folder \site_ruby\1.9.1\DBD\ADO just in case
     - I updated the SQL Server Path setting in Visual Studio to point to "C:\Program Files\Microsoft SQL Server\100\Tools\Binn"
What am I missing here?

I tried this on Windows XP and Windows 7 64-bit VMs with the same result. I'll go and try to use RailsInstaller 2.0.1 see if it helps.

Thanks,
Corix
Logged
corix
Newbie
*
Posts: 11


« Reply #4 on: February 02, 2012, 11:40:58 AM »

I tried using RailsInstaller 2.0.1 and I still get same result.  Sad
Logged
corix
Newbie
*
Posts: 11


« Reply #5 on: February 02, 2012, 01:55:46 PM »

I tried creating a sample app using SQLite and everything went well. It is just with SQL Server that is giving me problem and SQL Server is what we really use. Sad
Logged
Dermot
Administrator
Hero Member
*****
Posts: 1005


« Reply #6 on: February 02, 2012, 02:56:26 PM »

I think it might be an authentication issue. It looks like the wizard is failing to create the SQL database.

The command that creates the database from the 'Create Rails' wizard is output to the VS Output window. The code looks something like this:

Code:
if (f.Password == "") {
  p.StartInfo.Arguments = String.Format(@"/S /C """"{0}\sqlcmd.exe\"" -S{1} -i""{2}"" -U{3} -b -v databaseName=""{4}_{5}"" & echo %errorlevel%""", sqlCmdPath, f.Host, sqlFile, f.UserName, f.DatabaseName, dbType);
} else {
  p.StartInfo.Arguments = String.Format(@"/S /C """"{0}\sqlcmd.exe"" -S{1} -i""{2}"" -U{3} -P{4} -b -v databaseName=""{5}_{6}"" && exit 0""", sqlCmdPath, f.Host, sqlFile, f.UserName, f.Password, f.DatabaseName, dbType);
}

and you should see the string that sqlcmd tried to execute in the Output window prefixed by "/S /C". The way I normally test/troubleshoot issues like these is to copy the string and paste it into a command prompt (aka DOS box), remove the /S/C and extra quotes and try running it.

You should get the same error messages as before. Then I try and edit the command line and what it until it works. This elimiates all of the interaction between wizards and so on.

The actual SQL script that creates the SQL database is in C:\ProgramData\SapphireSteel Software\Ruby In Steel 2010\Scripts\sqlserver.sql. It might be that something needs to be modified in there.

In any event, you can always work round this problem by creating a Rails app with SQL Express and then editing the database yaml file to point to the SQL database that you want to use. The Rails app doesn't care once its been created - it just uses the parameter in the yaml file to connect to the database.

Try the above and see if you can find the cause to the problem and if you cant try editing the yaml file.

Dermot
Logged
corix
Newbie
*
Posts: 11


« Reply #7 on: February 02, 2012, 08:21:44 PM »

Hi Dermot,

Thank you so much for replying but I can't figure out what the command to type in the command prompt. Below is my failed attempt to come up with one:
 "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\"sqlcmd.exe -S ".\SQLEXPRESS" -i sqlFile -U "testuser" -P "testpass" -b -v databaseName="testdb_development" && exit 0
Can you please make corrections to this?

Also, there is no Scripts folder under my C:\Program Files\SapphireSteel Software\Ruby In Steel 2010\ directory hence no sqlserver.sql file as well.

- Corix
Logged
Dermot
Administrator
Hero Member
*****
Posts: 1005


« Reply #8 on: February 03, 2012, 08:36:50 AM »

Hi,

1) The command should be

Code:
"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\"sqlcmd.exe -S ".\SQLEXPRESS" -i sqlFile -U "testuser" -P "testpass" -b -v databaseName="testdb_development"

(that is, leave off the '&& exit 0')

2) the scripts are under ProgramData not Program Files

I'm trying to set up an SQL server database at the momemnt to see it there is a problem with the script - but it will take me a little time as we don't use SQLServer very much here, and I generally have it turned off.

Which version of SQLServer are you trying to use?

Dermot
Logged
corix
Newbie
*
Posts: 11


« Reply #9 on: February 03, 2012, 09:49:46 AM »

Thank you so much for taking your time assisting me with this issue. I really appreciate it.
What value should I use for -i sqlFile? is this the sqlserver.sql file which I don't have?

I have SQL Server 2008 R2 Express running on both my Windows 7 and Windows XP machines.

When I installed Ruby in Steel on both machines as described in the tutorial, it didn't create C:\ProgramData folder. Instead it installed itself to C:\Program Files\SapphireSteel Software\ on Windows XP and C:\Program Files (x86)\SapphireSteel Software\ on Windows 7 64 bit. The installation tutorial here http://www.sapphiresteel.com/Tutorials/Ruby-In-Steel-Tutorials/article/ruby-in-steel-2-tutorials also shows it is being installed in C:\Program Files folder too. Both Windows XP and Windows 7 Ruby in Steel installations are missing the Scripts folder and the sqlserver.sql file.

Could the missing folders and files be the reason why I am having the issue?

Again thank you very much.
Logged
Dermot
Administrator
Hero Member
*****
Posts: 1005


« Reply #10 on: February 03, 2012, 10:44:30 AM »

There should be a set of data files in the directory C:\ProgramData (for Vista and Windows 7). It's somewhere different for XP (I think it's under users directory, but I don't have XP installed right now). The ProgramData directory is where all the data files (as opposed to executables) are store. The execs are placed in 'C:\Program Data'. So, there are two main locations where files are installed and I think you must have them, so can you look again under

Code:
C:\ProgramData\SapphireSteel Software\Ruby In Steel 2010\Scripts

I'm having to re-install SQLServer - looks like my current installation is zapped beyond repair, so it will be a few hours before I can try it out properly.

I'll get back to you on the sqlfile thing when I've got SQLServer up and running.

Dermot
Logged
corix
Newbie
*
Posts: 11


« Reply #11 on: February 03, 2012, 11:32:39 AM »

Found it. It is hidden. I changed the windows setting to show hidden files and folders.

I modified the sqlserver.sql file to reflect the correct path to sql server express data folder:
     FILENAME = N'C:\Program Files\\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\$(databaseName).mdf'

Then when I issued the command on the command prompt I got the following:

C:\>"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\"sqlcmd.exe -S ".\SQLE
XPRESS" -i "C:\ProgramData\SapphireSteel Software\Ruby In Steel 2010\Scripts\sql
server.sql" -U "testuser" -P "testpass" -b -v databaseName="test05_development"
Changed database context to 'master'.
Creating test05_development
Msg 50000, Level 16, State 127, Server VIRTUALWIN7\SQLEXPRESS, Line 42
Database creation failed

What could be causing this?
« Last Edit: February 03, 2012, 12:41:54 PM by corix » Logged
corix
Newbie
*
Posts: 11


« Reply #12 on: February 03, 2012, 12:01:19 PM »

Oops I saw a typo:
    FILENAME = N'C:\Program Files\\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\$(databaseName).mdf'

I'm going to edit sqlserver.sql and try again.
Logged
corix
Newbie
*
Posts: 11


« Reply #13 on: February 03, 2012, 12:39:37 PM »

Negative.
The same result Sad
Logged
Dermot
Administrator
Hero Member
*****
Posts: 1005


« Reply #14 on: February 03, 2012, 01:20:59 PM »

Some progress ... I've installed a default SQLServer and I get the same error as you. However, if I change the TSQL catch clause to this:

Code:
BEGIN CATCH
SELECT ERROR_NUMBER() AS ErrorNumber
--RAISERROR('Database creation failed', 16, 127)
END CATCH

I get error 1802 - which I think is either a priv problem or possibly a log file location error. Something like that.

What OS are you using? I'm using Windows 7 x64

Dermot
Logged
Pages: [1] 2 Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!