• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 414
  • Last Modified:

ODBC Connection Failure to MySQL

I have installed mysql-4.1.4-gamma-win on a win2k pro pc and a win2k server both of which are used for development and testing.  SQl Server 2000 is installed on the server and is in use at the moment. I have had a few minor problems which I have worked through ok. I have copied a database with data from MSSQL to MySQL on both pcs.

My problem is that an ASP page run on the server will not connect. The error is "Data source name not found and no default driver specified". I have tried DSN and DSN-less connects. When I tested the DSN definition it connected fine on both pcs. The same ASP page works perfectly from the win2k pro pc, connecting to either the database locally or remotely on the server. In fact the page run on the pc from the server works great. I have had the above error before, usually when I have not setup a DSN definition or have mis-spelled the name. Connecting still works fine to the MSSQL server so I don't think it's something general with ODBC.

I have spent 2 days now "searching the web" for a solution to this problem so any help you can offer me would be greatly appreciated. Thanks Wayne.
1 Solution

       As you mentioned the common cause of the problem is in the connection string. You have mis-spelled the connction object in your connection string definition. Look for the connection string here.

dim Dbobj, DbobjMembers
Dbobj =  "Provider=sqloledb;Data Source=(local);Initial Catalog=PMS;User ID=PMSADMIN;Password=PMSADMIN"
Set DbobjMembers = Server.CreateObject("ADODB.CONNECTION")                ' may be you mis-spelled this object name
DbobjMembers.Open Dbobj


rwaynerAuthor Commented:

Thanks for your reply.

Unfortunately the oledb drivers for MySQL are defunct according to the experts including MySQL themselves so I will have to use ODBC.

Just to give a little more info I am using the same connection string from both pcs. Just changing the server name and user/password when connecting remotely.

These are the javascript definitions of the connection strings.
var ConnStr = "Driver={MySQL ODBC 3.51 Driver}; Server=localhost; Database=Logging; UID=root; PWD=rootpw; Option=3"
This works on the pc but not the server. It also works if this is run on the pc from the server.

var ConnStr = "Driver={MySQL ODBC 3.51 Driver}; Server=GDI-SERVER; Database=Logging; UID=user; PWD=user; Option=3"
This works from the pc to connect to the database on the server.

var ConnStr = "dsn=Logging;uid=root;pwd=rootpw;"
This works on the pc but not the server. Both dsn definitions test ok for connectivity when being defined.

I am going to try a different pc. This will be an xp pro pc. I possibly may be able to get acces to another win2k server. I will post again if I get any more info.
Do you have the latest MDAC from Microsoft? Also, have you tried creating a connection with the Data Sources (ODBC) tool in Windows? That might reveal basic connection problems that you could then easily resolve as opposed to trying to futz with ASP connection strings. Just a thought...

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

rwaynerAuthor Commented:
Thanks for your thoughts.

The pc has version 2.8 and the server has 2.6 which I have just updated to 2.8.  Yes. When defining a data source on pc and server the test connection is successful. It seems to be only when connecting from ASP that the issue arises.
Have you then tried to use that DSN instead of the connection string? Now this is important: You have to try the connection from the web server if you can. If you can create a remote desktop connection to the web server, then create the DSN there, you should then be able to use the DSN you create.

rwaynerAuthor Commented:
Yes I have tried a DSN connection which are defined on the server. A test connection works ok when defining the DSN.

I've just been able to try a connection from visual basic on the server. This works fine.
I used this connection string which will not work from ASP.
 "Driver={MySQL ODBC 3.51 Driver}; Server=localhost; Database=Logging; UID=root; PWD=rootpw; Option=3"
whcih leads me to think that I have got something, maybe security, setup wrong for the IIS user for MySQL.
rwaynerAuthor Commented:
I have discovered the problem.

The IUSR-Local_Machine user needs read permission for the registry keys HKLM\SOFTWARE\ODBC\ODBCINST.INI for dsn-less connections and HKLM\SOFTWARE\ODBC\ODBC.INI for dsn connections.

Thanks for your help.
PAQed with points refunded (500)

Community Support Moderator

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now