Connecting to MySql

Connecting to MySql

Postby Franklin Demont » 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: Select all  Expand view  RUN

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
Franklin Demont
 
Posts: 166
Joined: Wed Aug 29, 2012 8:25 am

Re: Connecting to MySql

Postby nageswaragunupudi » Mon Mar 13, 2017 12:32 pm

Code: Select all  Expand view  RUN
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
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Connecting to MySql

Postby Franklin Demont » Mon Mar 13, 2017 4: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
Franklin Demont
 
Posts: 166
Joined: Wed Aug 29, 2012 8:25 am

Re: Connecting to MySql

Postby anserkk » Tue Mar 14, 2017 3: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.
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Connecting to MySql

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 86 guests