Page 1 of 1

Connecting to MySql

Posted: Mon Mar 13, 2017 10:57 am
by Franklin Demont
I still have problems to connect , see also http://forums.fivetechsupport.com/viewt ... 70#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: Select all

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

Re: Connecting to MySql

Posted: Mon Mar 13, 2017 12:32 pm
by nageswaragunupudi

Code: Select all

oCn := FW_OpenAdoConnection( "MYSQL,localhost,pets,root,BRECHT", .t. )
if oCn == nil
   ? "Connect Fail"
else
   ? "connected"  
   // do your work
   oCn:Close()
endif
 

Re: Connecting to MySql

Posted: Mon Mar 13, 2017 4:25 pm
by Franklin Demont
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

Re: Connecting to MySql

Posted: Tue Mar 14, 2017 3:47 am
by anserkk
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.

Re: Connecting to MySql

Posted: Tue Mar 14, 2017 12:04 pm
by nageswaragunupudi
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.