ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
Re: Writing a SQL Query in Active Record?
by Phillip Gawlowski other posts by this author
May 8 2008 8:32AM messages near this date
Writing a SQL Query in Active Record? | Re: Writing a SQL Query in Active Record?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Anukul Singhal wrote:
| Hi,
|
| I am using the following code snippet for connecting to SQL Server
| through Active Record:
|
| require 'rubygems'
| require 'active_record'
|
| ActiveRecord::Base.establish_connection(
| :adapter =>  "sqlserver",
| :host =>  "xxx.xxx.xxx.xxx,8080"
| :username =>  "username"
| :password =>  "password"
| :database =>  "xyz_1008"
| )
|
| Now, I want to execute a query in this sql server after getting
| successfully connected but am not aware how to do so. Can anyone give an
| example as to how we write the query say ("Select * from Name") after
| establishing the above connection successfully?

ar.rubyonrails.com

Look for #find, or #find_by_sql.

- --
Phillip Gawlowski
Twitter: twitter.com/cynicalryan
Blog: http://justarubyist.blogspot.com

You write with ease to show your breeding,
But easy writing 's curst hard reading.
~ -- Richard Brinsley Sheridan (1751-1816)
~ -- Clio's Protest, Life of Sheridan (Moore), Vol. i, p. 155
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgjHOcACgkQbtAgaoJTgL9k8QCdHTVwPREoYlByjns1t1Sr9NOY
eYYAmgJ5A9zOn9ZrX8KgAUXwSz6oLORz
=KK/C
-----END PGP SIGNATURE-----
Thread:
Anukul Singhal
Phillip Gawlowski
Simon Krahnke
Phillip Gawlowski
Anukul Singhal
Phillip Gawlowski

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved