# SQL Server 2005 connection problems in XP

**URL:** <https://www.ruby-forum.com/t/sql-server-2005-connection-problems-in-xp/86399>\
**Category:** Ruby\
**Created:** [February 22, 2007, 12:05am UTC](https://www.ruby-forum.com/t/sql-server-2005-connection-problems-in-xp/86399 "2007-02-22T00:05:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gissell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3da27b/32.png) [@gissell](https://www.ruby-forum.com/u/gissell)\
**Post date:** [February 22, 2007, 12:05am UTC](https://www.ruby-forum.com/t/sql-server-2005-connection-problems-in-xp/86399/1 "2007-02-22T00:05:01Z")

</div>

Hello everyone,

I have been looking all over to see if I can get my problem resolved and  
alas, I have not been successful. Could someone help?

I am trying to connect to a database in XP that resides on a SQL Server  
2005. I downloaded and installed the Ruby-One-Time-Installer, so that  
gives me the odbc package.

The question is, how do I specify the datasource address if the database  
is residing on a server not on my local machine?

Here is a snip of my code:

require ‘DBI’

conn =  
DBI.connect(‘DBI:ODBC:fooServer\fooDevServer\Databases\db’,username,password)

Is this correct? I have changed to forward slashes, to colons, but to no  
avail. I keep getting the following error:

C:/INSTAN~1/ruby/lib/ruby/site\_ruby/1.8/DBD/ODBC/ODBC.rb:95:in  
`connect': IM002 (0) [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (DBI::DatabaseError) from C:/INSTAN~1/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:584:in`connect’  
from C:/INSTAN~1/ruby/lib/ruby/site\_ruby/1.8/dbi/dbi.rb:384:in  
`connect’  
from Database\_test.rb:18

Can someone let me know what I am missing?

Thanks,

Ana

---

<div class="post-metadata">

**Author:** ![gissell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3da27b/32.png) [@gissell](https://www.ruby-forum.com/u/gissell)\
**Post date:** [February 22, 2007, 2:50am UTC](https://www.ruby-forum.com/t/sql-server-2005-connection-problems-in-xp/86399/2 "2007-02-22T02:50:20Z")

</div>

On Feb 21, 5:05 pm, Ana L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> is residing on a server not on my local machine?
> 
> Thanks,
> 
> Ana
> 
> –  
> Posted viahttp://www.ruby-forum.com/.

So this “server” is a SQLExpress database file? You probably need an  
ODBC style connection string. This is my favest site in the world for  
connection strings: [http://connectionstrings.com/?carrier=sqlserver](http://connectionstrings.com/?carrier=sqlserver) I  
don’t even bother to remember 'em anymore. 🙂

---

<div class="post-metadata">

**Author:** ![gissell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3da27b/32.png) [@gissell](https://www.ruby-forum.com/u/gissell)\
**Post date:** [February 22, 2007, 4:09am UTC](https://www.ruby-forum.com/t/sql-server-2005-connection-problems-in-xp/86399/3 "2007-02-22T04:09:46Z")

</div>

Sam S. wrote:

> On Feb 21, 5:05 pm, Ana L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > is residing on a server not on my local machine?
> > 
> > Thanks,
> > 
> > Ana
> > 
> > –  
> > Posted viahttp://www.ruby-forum.com/.
> 
> So this “server” is a SQLExpress database file? You probably need an  
> ODBC style connection string. This is my favest site in the world for  
> connection strings: [http://connectionstrings.com/?carrier=sqlserver](http://connectionstrings.com/?carrier=sqlserver) I  
> don’t even bother to remember 'em anymore. 🙂

Hello,

Great! This certainly helped!

Ana

---

<div class="post-metadata">

**Author:** ![gissell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3da27b/32.png) [@gissell](https://www.ruby-forum.com/u/gissell)\
**Post date:** [February 22, 2007, 3:33pm UTC](https://www.ruby-forum.com/t/sql-server-2005-connection-problems-in-xp/86399/4 "2007-02-22T15:33:21Z")

</div>

Ana L. wrote:

> Sam S. wrote:
> 
> > On Feb 21, 5:05 pm, Ana L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> > 
> > > is residing on a server not on my local machine?
> > > 
> > > Thanks,
> > > 
> > > Ana
> > > 
> > > –  
> > > Posted viahttp://www.ruby-forum.com/.
> > 
> > So this “server” is a SQLExpress database file? You probably need an  
> > ODBC style connection string. This is my favest site in the world for  
> > connection strings: [http://connectionstrings.com/?carrier=sqlserver](http://connectionstrings.com/?carrier=sqlserver) I  
> > don’t even bother to remember 'em anymore. 🙂

As an added note, an ODBC connection needs to be created in Windows,  
seperate from your Ruby script. You can create an ODBC connection by  
going to the Control Panel-\>Administrative Tools-\>ODBC Data Source-\>User  
DSN-\>Add

This is what I really needed to figure out. Now I just use the name that  
I gave to my newly created datasource into my code and it works. Here is  
an example:

Data source was created with the name “fooDB”

require ‘DBI’

conn =  
DBI.connect(‘DBI:ODBC:fooDB’,username,password)
