Conexión a Base Datos

Post Reply
User avatar
gdeteran
Posts: 110
Joined: Fri Oct 14, 2005 7:10 pm
Location: Puerto Montt - CHILE

Conexión a Base Datos

Post 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
Saludos,
Gonzalo
Puerto Montt - CHILE
FWH 21.01 - Harbour 3.2.0dev (r2008190002) - Borland/Embarcadero C++ 7.0(32-bit)
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Conexión a Base Datos

Post 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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
gdeteran
Posts: 110
Joined: Fri Oct 14, 2005 7:10 pm
Location: Puerto Montt - CHILE

Re: Conexión a Base Datos

Post by gdeteran »

Thank you very much G. N. Rao, it worked perfect. I will start using the examples.
Saludos,
Gonzalo
Puerto Montt - CHILE
FWH 21.01 - Harbour 3.2.0dev (r2008190002) - Borland/Embarcadero C++ 7.0(32-bit)
Post Reply