ERROR [IM002] [Microsoft][ODBC Driver Manager]

D

Dakkar

I wrote a program with c# for connecting mysql and taking data from it
but when someone without me try to execute the program they are taking
this error


ERROR [IM002] [Microsoft][ODBC Driver Manager]
Data source name not found and
no default driver


is this somethin about odbc driver does every machine must have odbc
driver or just the mysql server machine?
Thanks
 
D

Dan Bass

ODBC requires a driver in order to access a database. Although it's a bridge
between your application and a database, it needs to know what database it's
talking too.

take a look here:
http://www.able-consulting.com/MDAC/ADO/Connection/ODBC_DSNLess.htm#ODBCDriverForMySQL

[beware of line wraps]

Hope that helps.

Dan.

Dakkar said:
I wrote a program with c# for connecting mysql and taking data from it
but when someone without me try to execute the program they are taking
this error


ERROR [IM002] [Microsoft][ODBC Driver Manager]
Data source name not found and
no default driver


is this somethin about odbc driver does every machine must have odbc
driver or just the mysql server machine?
Thanks
 
D

Dakkar

I think its because i didnt make the dsn is a system dsn but i dont
know how can i do it can somebody help me?

here is my connection code


MyCmd = new OdbcCommand();
MyConn = new OdbcConnection("DRIVER={MySQL ODBC 3.51
Driver};" + "SERVER=139.179.149.238;" +
"DATABASE=account;" + "UID=root;" +
"PWD=root;" + "OPTION=3;");
MyConn.Open();
MyCmd.Connection = MyConn;
 
D

Dan Bass

Jakka,

You don't need a DSN (data source name) because you've wrapped up the server
address, driver and database details in your connect string.

What a DSN does allow you to do though, is to move this logic into system
settings so that all you need do is specify a DSN name, and the other
details here are not required (driver included). Another huge benefit is the
ability to test a DSN connection before you even use the connection in your
code.

To create a DSN for your connection, go to "Start->Control
Panel->Administrative Tools->Data Sources(ODBC)".
There's a System DSN tab there for DSN's that any user that logs on can
access.
Click Create New... the rest is quite self explanatory, but let me know if
you've any problems.
At the end of creating the connection there's a "Test" button somewhere that
open and closes the connection for you to decide whether it's valid
configuration.

In your code all you need to do is specify the name of your DSN, plus a uid
and pwd...
http://www.able-consulting.com/MDAC/ADO/Connection/ODBC_DSN.htm#DSN

good luck.

Dakkar said:
I think its because i didnt make the dsn is a system dsn but i dont
know how can i do it can somebody help me?

here is my connection code


MyCmd = new OdbcCommand();
MyConn = new OdbcConnection("DRIVER={MySQL ODBC 3.51
Driver};" + "SERVER=139.179.149.238;" +
"DATABASE=account;" + "UID=root;" +
"PWD=root;" + "OPTION=3;");
MyConn.Open();
MyCmd.Connection = MyConn;
 
D

Dan Bass

Dakkar,

Another suggestion on this is to move away from ODBC. A connector to the
MySQL database would be better...

http://www.able-consulting.com/dotnet/adonet/Data_Providers.htm#MySQLDirectNETDataProvider

Thanks.

Dan.


Dan Bass said:
Dakkar,

You don't need a DSN (data source name) because you've wrapped up the
server address, driver and database details in your connect string.

What a DSN does allow you to do though, is to move this logic into system
settings so that all you need do is specify a DSN name, and the other
details here are not required (driver included). Another huge benefit is
the ability to test a DSN connection before you even use the connection in
your code.

To create a DSN for your connection, go to "Start->Control
Panel->Administrative Tools->Data Sources(ODBC)".
There's a System DSN tab there for DSN's that any user that logs on can
access.
Click Create New... the rest is quite self explanatory, but let me know if
you've any problems.
At the end of creating the connection there's a "Test" button somewhere
that open and closes the connection for you to decide whether it's valid
configuration.

In your code all you need to do is specify the name of your DSN, plus a
uid and pwd...
http://www.able-consulting.com/MDAC/ADO/Connection/ODBC_DSN.htm#DSN

good luck.
 
M

Michael Voss

Hi!
I think its because i didnt make the dsn is a system dsn but i dont
know how can i do it can somebody help me?

here is my connection code


MyCmd = new OdbcCommand();
MyConn = new OdbcConnection("DRIVER={MySQL ODBC 3.51
Driver};" + "SERVER=139.179.149.238;" +
"DATABASE=account;" + "UID=root;" +
"PWD=root;" + "OPTION=3;");
MyConn.Open();
MyCmd.Connection = MyConn;
[...snip...]

Make sure the MySQL ODBC 3.51 Driver is installed on the client machine and
the server can be contacted from the client. As Dan suggested, it is a good
idea to create a system ODBC data source on all client machines (let's call
it MYODBC) encapsulating all the information you provide in your connection
string (maybe except UID and PWD; these should be provided by your
application). So you can connect using something like

myConn = new OdbcConnection("DSN=MYODBC;UID=root;PWD=root;");
myConn.Open();

So, you will most likely encounter less problems on other client machines
(e. g. driver has other version, client uses other database server etc.).
 
D

Dakkar

so you re saying if someone out of my computer wants to acces my mysql
they have to have the myodbc 3.51 driver?

So how can i import this driver into my program because i cant say
everyone "Download and install this driver"
Thanks
 
M

Michael Voss

Hi!
so you re saying if someone out of my computer wants to acces my mysql
they have to have the myodbc 3.51 driver?

Yes. You actually specify what ODBC driver to use in your "connection
string". This is why I suggested creating an ODBC data source with a
specified name. To each client can have another version of the ODBC driver
installed (to some extent, they have to be compatible with what you intend
to do). If there is no ODBC driver for MySql installed, you cannot connect
to MySql using ODBC. That's why Dan suggested using a native way of
connecting to MySql: No ODBC driver needed.
So how can i import this driver into my program because i cant say
everyone "Download and install this driver"

Sorry, that's what you have to do, basically: Ask your users to install the
appropriate ODBC driver on their local machine. This is the only way to go
if you want to use ODBC (unless someone else knows some different
approach...). Think about Dan's suggestion.

[...snip...]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top