Page 1 of 1

Conexión a Base Datos

Posted: Fri Nov 23, 2018 12:08 am
by gdeteran
Ayuda por favor:

1) A traves de DBF2SQL transformé tablas DBF a SQL. Los datos creados los he podido ver con HeidiSQL, NaviCat, MySqlQueryBrowser sin ningun problema

2) Intento abrir alguna de las tablas de la siguente forma:

Code: Select all

   local cServer     := "localhost"
   local cDataBase   := "FacNit"
   local cUser       := "root"
   local cPassWord   := "348500"

   ? "Start"
   oCn   := FW_OpenAdoConnection( { "MYSQL", cServer, cDataBase, cUser, cPassword }, .t. )
   if oCn == nil
      ? "Connection Fail"
      return nil
   else
      ? "Connected"
   endif
 

y me arroja este error:

Code: Select all

[Microsoft][Administrador de controladores ODBC] No se
encuentra el nombre del origen de datos y no se especificó
ningun controlador predeterminado
Source         : Microsoft OLE DB Provider for ODBC Drivers
NativeError  : 0
Error Source: Microsoft OLE DB Provider dor ODBC Drivers
Sql State     : IM002
------------------------------------------
FW_OPENADOCONNECTION( 128 )

De antemanos, gracias

Re: Conexión a Base Datos

Posted: Fri Nov 23, 2018 12:25 am
by nageswaragunupudi
For working with ADO, you need to download and install MySql ODBC connector. That is the reason for the error you are getting.

Because you are using FWH 18.01, it is a lot easier to connect to and work with MySql tables using the inbuilt functionality of FWH.

Please open \fwh\samples\maria01.prg
You will see this in line 14.

Code: Select all

   oCn   := FW_DemoDB()
 
Please change this as:

Code: Select all

   oCn := maria_Connect( "localhost", "FacNit", "root", "348500" )
 
Save the file in the same \fwh\samples folder and build and run with

Code: Select all

buildh maria01
// or
buildx maria01
 
You will get a message if you are connected or not and if connected, you will see a list of all tables and then if you double-click on any table you will see a browse of that table.
This is a good start for working with MySQL database with FWH.

Re: Conexión a Base Datos

Posted: Fri Nov 23, 2018 9:45 pm
by gdeteran
Thank you very much G. N. Rao, it worked perfect. I will start using the examples.