[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby + sql server

Faby

3/30/2007 11:51:00 AM

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

2 Answers

james.adam

4/1/2007 3:02:00 PM

0

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.

--
* J *
~

grooveska

4/4/2007 8:59:00 PM

0

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...