Forum: Ruby Ruby + sql server

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8a3474a7a080e80576fecb87c0f12f99?d=identicon&s=25 Faby (Guest)
on 2007-03-30 13:56
(Received via mailing list)
Hi,
I would like to execute a stored procedure using ruby and sql server
2000 with DBI and ODBC.
Can anyone give me an example on how to do it?
Thanks
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 James Adam (Guest)
on 2007-04-01 17:02
(Received via mailing list)
On 3/30/07, Faby <stardust99_fr@yahoo.fr> wrote:
> Hi,
> I would like to execute a stored procedure using ruby and sql server
> 2000 with DBI and ODBC.
> Can anyone give me an example on how to do it?
> Thanks

Probably the simplest way is use ruby-dbi to open a connection, and
then run the "EXEC <your stored procedure>" SQL as a regular
statement. You should find plenty of resources on the web about using
ruby-dbi.
Dc27e085e5b089e8f0f2eee9621417e5?d=identicon&s=25 grooveska (Guest)
on 2007-04-04 23:01
(Received via mailing list)
On Mar 30, 6:51 am, "Faby" <stardust99...@yahoo.fr> wrote:
> Hi,
> I would like to execute a stored procedure using ruby and sql server
> 2000 with DBI and ODBC.
> Can anyone give me an example on how to do it?
> Thanks

Here is what worked for me:

I made an ODBC System DSN named ruby to the DB & Server I wanted to
connect to.

so my ruby script looks like this:

require "dbi"

db = DBI.connect('dbi:ODBC:ruby', 'sa', 'UMsys#07')

storedproc = "EXEC createUser @userName=bob, @password=bob"

stmt = db.prepare(storedproc)
stmt.execute

puts "User Created"

stmt.finish
db.disconnect

Hope that helps...
This topic is locked and can not be replied to.