FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Ayuda con Mysql
Posts: 0
Joined: unknown
Ayuda con Mysql
Posted: Wed Jul 08, 2020 11:22 AM

Hola gente, buen d铆a, necesito ayuda para conectarme con mysql.

Instale mysql, workbench, el driver y logr茅 con el UDL generar la cadena de conexi贸n.

El tema es que cuando quiero conectarme con ADODB no logro conectarme, tambien tengo instalado en otra pc sqlexpress y la conexi贸n funciona perfecto.

La conexi贸n es "Provider=MSDASQL.1;Password=Cava1234;Persist Security Info=True;User ID=root;Data Source=jpcavagnaro;Initial Catalog=restaurate"

Que me falta instalar?

Saludos.
Jorge.

Posts: 411
Joined: Sun Jan 31, 2010 03:30 PM
Re: Ayuda con Mysql
Posted: Wed Jul 08, 2020 11:52 AM
Buen dia. Espero le sirva

Johnson Russi

Code (fw): Select all Collapse
static function ConnectToServerSql(oCon,cTipCon,cDirSer,cDatBas,cUseBas,cPasUse)

聽 聽

聽 聽LOCAL cPath := CURDRIVE() + ':\\' + CURDIR()+";"
聽 聽LOCAL lConnect := .f.
聽 聽LOCAL cDriSql := ""


聽 聽DO CASE

聽 聽 聽 CASE cTipCon == "MYSQL"

聽 聽 聽 聽 聽 聽 cDriSql := "DRIVER={MySQL ODBC 3.51 Driver}; SERVER="+cDirSer+"; DATABASE="+cDatBas+"; "+;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽"UID="+cUseBas+";PASSWORD="+cPasUse+"; OPTION=3"

聽 聽 聽 CASE cTipCon == "MSSQL"

聽 聽 聽 聽 聽 聽//cDriSql := "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=MANAGER;User Id=sa;Password=xxx"
聽 聽 聽 聽 聽 聽cDriSql := "Provider=SQLOLEDB;Data Source="+cDirSer+";Initial Catalog="+cDatBas+";User Id="+cUseBas+";Password="+cPasUse+";"

聽 聽ENDCASE

聽 // cDriSql := "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=" + cPath // + "\"+M->cPatSis

// 聽cDriSql := 聽"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+cPath+";Extended Properties=DBASE IV"


// 聽 cDriSql :="DRIVER={PostgreSQL Unicode};Server=localhost;Port=5433;Database=russoft_01;UID=user_xxx;PWD=xxx;"


聽// 聽 cDriSql := "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=MANAGER;User Id=sa;Password=xxx"


/*
聽 聽 cDriSql := "Provider=PostgreSQL OLE DB Provider;"+;
聽 聽 聽 聽 聽 聽 聽 聽"Location=russoft1_zerus;"+;
聽 聽 聽 聽 聽 聽 聽 聽"Data Source=www.russoft.co;"+;
聽 聽 聽 聽 聽 聽 聽 聽"User ID=russoft1_zerus;"+;
聽 聽 聽 聽 聽 聽 聽 聽"PORT=5432;"+;
聽 聽 聽 聽 聽 聽 聽 聽"Password=901120;"


聽 聽 聽 聽 聽 聽 聽 聽 //"PORT=5432;" 聽// 聽Extended"

*/

聽 聽if oCon == nil
聽 聽 聽 oCon 聽 聽 聽 聽 聽 聽 聽 聽 聽 := TOleAuto():new("ADODB.Connection")
聽 聽 聽 oCon:ConnectionString 聽:= cDriSql
聽 聽 聽 TRY
聽 聽 聽 聽 聽oCon:Open()
聽 聽 聽 聽 聽lConnect := .t.
聽 聽 聽 CATCH
聽 聽 聽 聽 聽oCon 聽 聽 聽 聽 聽 聽 聽 聽 聽:= nil
聽 聽 聽 聽 聽MyMen("Error. No fue posible la conexi垄n con el servidor SQL" )
聽 聽 聽 聽 聽return .F.
聽 聽 聽 END
聽 聽else
聽 聽 聽 lConnect := .t.
聽 聽endif

return lConnect
Posts: 0
Joined: unknown
Re: Ayuda con Mysql
Posted: Wed Jul 08, 2020 02:16 PM

No me funciona,

include "fivewin.ch"

include "ado.ch"

FUNCTION MAIN()

LOCAL cPath := CURDRIVE() + ':\' + CURDIR()+";"
LOCAL lConnect := .f.
LOCAL cDriSql := ""

cDriSql := "DRIVER={MySQL ODBC 8.0 Unicode Driver};UID=root;PASSWORD=xxxx;PORT=3306;SERVER=localhost;DATABASE=restaurate; OPTION=3"

*"DRIVER={MySQL ODBC 3.51 Driver}; SERVER="+cDirSer+"; DATABASE="+cDatBas+"; "+;
* "UID="+cUseBas+";PASSWORD="+cPasUse+"; OPTION=3"

  oCon                   := TOleAuto():new("ADODB.Connection")
  oCon:ConnectionString  := cDriSql
  TRY
     oCon:Open()
     lConnect := .t.
  CATCH oError
      showError( oError )
  END

return lConnect

Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: Ayuda con Mysql
Posted: Wed Jul 08, 2020 04:30 PM

jpcavagnaro

Necesitas tener instalado el conector, lo tienes?

Este debe ser de la misma versi贸n que tienes definida en la cadena de conexi贸n

Driver={MySQL ODBC 5.1 Driver} o Driver={MySQL ODBC 3.51 Driver}

Saludos

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Ayuda con Mysql
Posted: Wed Jul 08, 2020 05:11 PM
You can connect to MySql through ADO or directly with FWH inbuilt MySql library.
You propose to connect and work using ADO.

For this, you need to download and install MySql ODBC connector on every PC using your software. We assume you have installed the ODBC connector.

We advise you not to make your own connection strings for any server, be it MySql, MSSql, Oracle, etc. If you prepare your own connection strings you need to know the version of ODBC driver or OLEDB provider. When we provide software to several clients they may have already installed different versions of ODBC drivers/OLEDB providers.

Instead use FWH built-in ADO functions.

Code (fw): Select all Collapse
oCn := FW_OpenAdoConnection( { "MYSQL", cServer, cDatabase/InitialCatalog, cUser, cPassword }, .t. )
if oCn == nil
   ? "fail"
else
   ? "connected"
   // do your work
   oCn:Close()
endif


You can use the same function for MSSQL, Oracle, etc by changing "MYSQL" to "MSSQL" or "ORACLE".

This function checks the version of ODBC driver/OLEDB provider installed on the target PC and uses the latest version installed.

In other words, your program will work on a PC with ODBC 5.1 installed or ODBC 8.0 installed.

All the FWH ADO functions support DBASE, FOXPRO, ACCESS, MSSQL, MYSQL, ORACLE.
They work with any other OLEDB provider if the programmer provides connection string.

Using FWH ADO functions greatly simplifies your work.
For all functions please see fwh\source\function\adofuncs.prg

For working with MySql, you may also consider using the inbuilt MySql library of FWH. For using this, you need not get the ODBC connectors installed on all your clients' PCs. You simply provide your exe with libmysql.dll (provided by FWH ).
Regards



G. N. Rao.

Hyderabad, India
Posts: 0
Joined: unknown
Re: Ayuda con Mysql
Posted: Wed Jul 08, 2020 08:36 PM
Armando wrote:jpcavagnaro

Necesitas tener instalado el conector, lo tienes?

Este debe ser de la misma versi贸n que tienes definida en la cadena de conexi贸n

Driver={MySQL ODBC 5.1 Driver} o Driver={MySQL ODBC 3.51 Driver}

Saludos


Hola Armando, tengo instalado el MySQL ODBC 8.0, tiene que ser la versi贸n 3 o 5 ?

Saludos
Jorge.
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: Ayuda con Mysql
Posted: Wed Jul 08, 2020 09:24 PM

jpcavagnaro

Intenta con el conector de alguna de las dos versiones 3.51 o 5.1 y
en la cadena de conexi贸n debes especificar que versi贸n de conector
instalaste.

Driver={MySQL ODBC 5.1 Driver} o Driver={MySQL ODBC 3.51 Driver}

Cual es tu correo?

Saludos

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 0
Joined: unknown
Re: Ayuda con Mysql
Posted: Wed Jul 08, 2020 09:49 PM
Armando wrote:jpcavagnaro

Intenta con el conector de alguna de las dos versiones 3.51 o 5.1 y
en la cadena de conexi贸n debes especificar que versi贸n de conector
instalaste.

Driver={MySQL ODBC 5.1 Driver} o Driver={MySQL ODBC 3.51 Driver}

Cual es tu correo?

Saludos


jpcavagnaro@yahoo.com.ar
Posts: 0
Joined: unknown
Re: Ayuda con Mysql
Posted: Thu Jul 09, 2020 11:54 AM

Ya me pude conectar, me faltaba abrir el puerto.

Saludos.
Jorge.

Posts: 0
Joined: unknown
Re: Ayuda con Mysql
Posted: Thu Jul 09, 2020 07:35 PM

De nuevo, alguien me podria pasar un ejemplo de un abm, no logro abrir las tablas.

Algo me falta hacer seguro, porque por ej.

cSQL := "select * from clientes "

oRSSTK := CargaRecordSet( cSQL, oCon)

xbrowse( oRSSTK, "Fijate", .t.,,, .t., .t., .t. )

Esto con SQLServer me funciona perfecto.

Saludos
Jorge.

Posts: 0
Joined: unknown
Re: Ayuda con Mysql
Posted: Thu Jul 09, 2020 08:29 PM

Cree una base por Workbench y pude abrila sin problema, la que genere como ejemplo (que baje el sql) y no se porque no abre.

Pero bueno creando mis bases funciona por ahora todo bien.

Gracias

Saludos.
Jorge.

Posts: 0
Joined: unknown
Re: Ayuda con Mysql
Posted: Fri Jul 10, 2020 10:22 PM

Hola gente, tengo un problema, genero esta tabla:

CREATE TABLE Clientes1 (
id int(11) NOT NULL AUTO_INCREMENT,
Numero decimal( 6, 0),
Domicleg character( 100),
Zona decimal( 10, 0),
Con_iva decimal( 1, 0),
Cuit character( 13),
Nombre character( 40),
Domic character( 40),
Loca character( 40),
Tele character( 50),
Copo character( 10),
Vendedor decimal( 4, 0),
Ctacte character( 1),
Bonif decimal( 6, 2),
Tope decimal( 10, 2),
Email character( 30),
PRIMARY KEY (id)
)

y no puedo acceder, lo que descubro es que cambio los datos decimal por double y ah铆 si puedo abrirla.

porque puede ser este problema con los tipos de datos.

Saludos.
Jorge

Continue the discussion