FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Connecting to MySql
Posts: 166
Joined: Wed Aug 29, 2012 08:25 AM
Connecting to MySql
Posted: Mon Mar 13, 2017 10:57 AM
I still have problems to connect , see also viewtopic.php?f=3&t=32470#p195453
During a few days i could make connection , from then no connection anymore.

Now , i try to start from scratch on a new computer. What i am doing wrong ?

From MySql site dowmload and install MySql\mysql-installer-web-community-5.7.17.0.msi
MySql\mysql-connector-odbc-5.3.7-win32.msi


c:\Program Files (x86)\MySQL\Connector ODBC 5.3 is created , running c:\Program Files (x86)\MySQL\Connector ODBC 5.3\myodbc-installer.exe

myodbc-installer -d -l

Shows a list from drivers , last two from list :

MySQL ODBC 5.3 ANSI Driver
MySQL ODBC 5.3 Unicode Driver

I suppose that i have also to register the ansi driver with

myodbc-installer -d -a -n "MySQL ODBC 5.3 ANSI Driver" -t "DRIVER=myodbc5a.dll;SETUP=myodbc5S.dll"

Respons from the program : Success: Usage count is 3

After that i can use MySql 5.7 Command Line Client , creating some users and databases.

Also tDolphin is working and create some databases with tables , populating them

Using windows ODBC system manager i can add and configure MySql ODBC Driver (MySQL ODBC 5.3 ANSI Driver) .
Data Source Name : MySQL ODBC 5.3 ANSI Driver
TCP/IP Server : ..... Port : 3306
User : Root , PassWord : BRECHT
Test the connection seems ok .
I am sure that user , server , database and password are correct.

Running the FW aplication :

Code (fw): Select all Collapse
FUNC TestMySqlCon()
local cCon , c
local oCon , oErr , lOk := .F.
cCon := "{MySQL ODBC 5.3 ANSI Driver};Server=localhost;Database=pets;User=root;Password=BRECHT;Option=3;"
Try
   oCon   := TOleAuto():New( "ADODB.Connection" )
End Try

oCon:CursorLocation := 3        // local cache

TRY
   oCon:Open( cCon )
CATCH oErr
  ? oErr:Description , "Could not open a Connection to Database " , cCon  , Procname() , procline() , Procname(1) , procline(1)
  Return nil
END TRY


RETURN oCon


I got as error (trying to translate in english) :

[Microsoft][ODBC-driver Manager]The data source name is not found and no default driver specified(0x8004005)
Could not open a connection to Database {MySQL ODBC 5.3 ANSI Driver};Server=localhost;Database=pets;User=root;Password=BRECHT;Option=3;


WHAT AM I DOING WRONG OR WHAT AM I MISSING ?????

Frank
test
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Connecting to MySql
Posted: Mon Mar 13, 2017 12:32 PM
Code (fw): Select all Collapse
oCn := FW_OpenAdoConnection( "MYSQL,localhost,pets,root,BRECHT", .t. )
if oCn == nil
   ? "Connect Fail"
else
   ? "connected"  
   // do your work
   oCn:Close()
endif
Regards



G. N. Rao.

Hyderabad, India
Posts: 166
Joined: Wed Aug 29, 2012 08:25 AM
Re: Connecting to MySql
Posted: Mon Mar 13, 2017 04:25 PM

Sorry , as expected the same result.

The FW routine builds exact the same connection string and after creating the ADODB.connection
it executes :

oCn:Open( cCon )

The real question is : how install MYSQL with ODBC connector ?

1) download and install MySql\mysql-installer-web-community-5.7.17.0.msi
MySql\mysql-connector-odbc-5.3.7-win32.msi

and then ? must the ansi driver be registered ?
Have we to use ODBC Manager ?

When it doesn't work , may be a windows setting or mysql setting must be changed. Which ?

Frank

test
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Connecting to MySql
Posted: Tue Mar 14, 2017 03:47 AM

If you use FWH's inbuilt MySQL features, then you don't have to install ODBC Drivers for MySQL, but If you are planning to use ADO then you need to have the MySQL ODBC drivers installed on all the PC's supposed to run your application.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Connecting to MySql
Posted: Tue Mar 14, 2017 12:04 PM

It appears that your installation is correct. Just download the msi file and run it. That is all.
Your code also appears to be correct.
I am unable to find any reason for failure.
May be some other ADO user can find the problem.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion