views:

128

answers:

3

Hi there,

I am having major trouble connecting to my database via ODBC.

The db is local (but I have a mirror on a virtual machine), so I am trying to use the connectionstring:

Dsn=MonetDB;host=TARBELL

where TARBELL is the name of my computer. However, it doesn't connect. BUT, this string does:

Dsn=MonetDB;host=localhost

as does

Dsn=MonetDB

Can anyone explain this? I am at a complete loss.

I have taken down my firewalls (at least until I get this figured out), so that can't be the problem.

I eventually want to change the TARBELL to the mirrored virtual machine running another instance of the database.

Many thanks, Brett

+1  A: 

I've never seen a "host" parameter for a DSN type connection string. DSN's are either stored with the user, the system or as a file. The way you have referenced your DSN here, it is either stored under your user account or with the system. With a DSN, all the credentials and information about which server and driver to be used are stored in the DSN. If you want control over those parameters, you should consider a DSN-less connection string like so:

"Driver={Mysql}; Server=[server_name];Port=[port_number]; Database=[database_name];UID=[username]; PWD=[password]"
Thomas
+2  A: 

I can recommend connectionstrings.com for details on the supported syntax across all of the supported ADO.NET providers.

Morten Mertner
+1  A: 

DNS usually resolves TARBALL and localhost differently. You can see with ping:

c:\>ping tarball
Pinging tarball [192.168.1.99] with 32 bytes of data:
                 ^^^^^^^^^^^^

c:\>ping localhost
Pinging tarball [127.0.0.1] with 32 bytes of data:
                 ^^^^^^^^^

The computer name resolves to the external IP, while localhost resolves to the special IP 127.0.0.1 that always points at the local machine. Some installations of MySQL listen on localhost only, so if you specify the computer name, they stop listening.

This behaviour is configured using the bind-address option:

--bind-address=127.0.0.1

Or the equivalent (MySQL also uses DNS to resolve hostnames):

--bind-address=localhost 

To make the server listen on all interfaces, specify:

--bind-address=0.0.0.0

On Windows, MySQL reads configuration options from:

WINDIR\my.ini, WINDIR\my.cnf
C:\my.ini, C:\my.cnf
INSTALLDIR\my.ini, INSTALLDIR\my.cnf

See the MySQL manual pages for some more information.

Andomar