FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Pasar tablas SQL Server a DBF
Posts: 1276
Joined: Tue Dec 28, 2010 01:29 PM
Re: Pasar tablas SQL Server a DBF
Posted: Thu Jul 13, 2017 04:58 PM
cnavarro wrote:Intenta no cerrando el oRs:Close()


El mismo error

Can not create OCRD

FWH 25.12

Harbour/Hbmk2

Microsoft Visual C++

MySql 8.0

Antigravity

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Pasar tablas SQL Server a DBF
Posted: Thu Jul 13, 2017 05:42 PM

Intenta ponerle el path completo donde quieras crearlo

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1276
Joined: Tue Dec 28, 2010 01:29 PM
Re: Pasar tablas SQL Server a DBF
Posted: Thu Jul 13, 2017 05:45 PM

Tampoco

FWH 25.12

Harbour/Hbmk2

Microsoft Visual C++

MySql 8.0

Antigravity

Posts: 1276
Joined: Tue Dec 28, 2010 01:29 PM
Re: Pasar tablas SQL Server a DBF
Posted: Thu Jul 13, 2017 07:29 PM

Mr Rao,

Any advise?

FWH 25.12

Harbour/Hbmk2

Microsoft Visual C++

MySql 8.0

Antigravity

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Pasar tablas SQL Server a DBF
Posted: Thu Jul 13, 2017 07:35 PM

Tampoco est谩s cerrando la conexi贸n oCn:Close antes verdad?

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1276
Joined: Tue Dec 28, 2010 01:29 PM
Re: Pasar tablas SQL Server a DBF
Posted: Thu Jul 13, 2017 07:44 PM
cnavarro wrote:Tampoco est谩s cerrando la conexi贸n oCn:Close antes verdad?


Cristobal,

Haciendolo de esta manera:

#include "FiveWin.ch"

//----------------------------------------------------------------//

REQUEST DBFCDX

function Main()
local cServer := "localhost\SQLEXPRESS"
local cUser := "SA"
local cPassword := "1234"
local cDatabase := "SBODemoUS"
local cTable := "OCRD"
local oCn, oRs, cDbf:="OCRD", lEditStruct:= .F.

oCn := FW_OpenAdoConnection( { "MSSQL", cServer, cDatabase }, .t. )
if oCn == nil
? "Connect Fail"
else
oRs := FW_OpenRecordSet( oCn, cTable )
if oRs == nil
? "Fail to open table"
else
XBROWSER oRs FASTEDIT TITLE cTable

endif

endif

FW_AdoExportToDBF( oRs, cDbf, lEditStruct )

oRs:Close()

oCn:Close()


return nil
//----------------------------------------------------------------//

Funciono!! Se creo el DBf y se lleno con los datos de la tabla,

Ahora, como podria hacer para que me tome todas las tablas de la Base de Datos sin tener que nombrarlas 1 por 1 ?

FWH 25.12

Harbour/Hbmk2

Microsoft Visual C++

MySql 8.0

Antigravity

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Pasar tablas SQL Server a DBF
Posted: Thu Jul 13, 2017 08:28 PM

No podia funcionar con la conexion cerrada

Prueba con FW_AdoTables( oCn )

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1276
Joined: Tue Dec 28, 2010 01:29 PM
Re: Pasar tablas SQL Server a DBF
Posted: Fri Jul 14, 2017 02:42 PM
cnavarro wrote:No podia funcionar con la conexion cerrada

Prueba con FW_AdoTables( oCn )



Hola Cristobal, utilizando este codigo

#include "FiveWin.ch"

//----------------------------------------------------------------//

REQUEST DBFCDX

function Main()
local cServer := "localhost\SQLEXPRESS"
local cDatabase := "SBODemoUS"
local oCn, oRs, aTables, cTable

oCn := FW_OpenAdoConnection( { "MSSQL", cServer, cDatabase }, .t. )

aTables := FW_AdoTables( oCn )

if oCn == nil
? "Connect Fail"
else

XBROWSER aTables

endif

FOR EACH cTable IN aTables
oRs := FW_OpenRecordSet( oCn, cTable )
FW_AdoExportToDBF( oRs, cTable, .F. )
oRs:Close()
NEXT

? "EXPORTACION FINALIZADA"

oCn:Close()


return nil
//----------------------------------------------------------------//


Comienza a realizar la exportacion de las tablas a archivos .Dbf, pero luego se detiene y arroja este error

Incorrect syntax near the keyword 'CASE'
Source : Microsoft SQL Server Native Client 11.0
NativeError: 156
Error Source: Microsoft SQL Server Native Client 11.0
Sql State: 42000
--------------------------------------------
FW_OPENRECORDSET( 437 )


Mas

Application
===========
Path and name: C:\fwh1705\samples\mssql01.exe (32 bits)
Size: 3,793,920 bytes
Compiler version: Harbour 3.2.0dev (r1703231115)
FiveWin version: FWH 17.05
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.2, Build 9200

Time from start: 0 hours 0 mins 22 secs
Error occurred at: 07/14/17, 11:04:27
Error description: Error BASE/1004 No exported method: FIELDS
Args:
[ 1] = U

Stack Calls
===========
Called from: => FIELDS( 0 )
Called from: .\source\function\ADOFUNCS.PRG => FWADOSTRUCT( 1747 )
Called from: .\source\function\ADOFUNCS.PRG => FW_ADOEXPORTTODBF( 1192 )
Called from: mssql01.prg => MAIN( 26 )



Algun advise ?

FWH 25.12

Harbour/Hbmk2

Microsoft Visual C++

MySql 8.0

Antigravity

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Pasar tablas SQL Server a DBF
Posted: Sun Jul 16, 2017 12:07 PM
Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local cServer     := "SQLEXPRESS" 
   local cUser       := "SA" 
   local cPassword   := "1234" 
   local cDatabase   := "SBODemoUS" 
   local cTable      := "RCD" 
   local cdbf        := "RCD.DBF"
   local lEditStruct := .F. 
   local oCn, oRs
   
   oCn   := FW_OpenAdoConnection( { "MSSQL", cServer, cDatabase, cUser, cPassword }, .t. )

   if oCn == nil
      ? "Connect Fail"
   else
      ? "Connected."
      oRs   := FW_OpenRecordSet( oCn, cTable )
      if oRs == nil
         ? "Can not open " + cTable
      else
         XBROWSER oRs FASTEDIT
         cDBF     := cFileSetExt( cDBF, "dbf" )
         FW_AdoExportToDBF( oRs, cDbf, .t. )
         XBROWSER cDBF FASTEDIT
         oRs:Close()
      endif
      oCn:Close()
   endif

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 1276
Joined: Tue Dec 28, 2010 01:29 PM
Re: Pasar tablas SQL Server a DBF
Posted: Sun Jul 16, 2017 01:00 PM
Thank you Mr Rao

I did it before just for one DBF and works fine. I have to do it for 2140 tables.

Now I need to add all the database tables in one array, which works too, and then export to MySQl.

Code (fw): Select all Collapse
#include "FiveWin.ch"

//----------------------------------------------------------------//

REQUEST DBFCDX

function Main()
local cServer := "localhost\SQLEXPRESS"
local cDatabase := "SBODemoUS"
local oCn, oRs, aTables, cTable

oCn := FW_OpenAdoConnection( { "MSSQL", cServer, cDatabase }, .t. )

aTables := FW_AdoTables( oCn ) 

if oCn == nil
? "Connect Fail"
else

XBROWSER aTables

endif 

FOR EACH cTable IN aTables
oRs := FW_OpenRecordSet( oCn, cTable )
FW_AdoExportToDBF( oRs, cTable, .F. )
oRs:Close()
NEXT

? "EXPORTACION FINALIZADA"

oCn:Close()


return nil
//----------------------------------------------------------------//


Comienza a realizar la exportacion de las tablas a archivos .Dbf, pero luego se detiene y arroja este error

Incorrect syntax near the keyword 'CASE'
Source : Microsoft SQL Server Native Client 11.0
NativeError: 156
Error Source: Microsoft SQL Server Native Client 11.0
Sql State: 42000
--------------------------------------------
FW_OPENRECORDSET( 437 )


Mas

Application
===========
Path and name: C:\fwh1705\samples\mssql01.exe (32 bits)
Size: 3,793,920 bytes
Compiler version: Harbour 3.2.0dev (r1703231115)
FiveWin version: FWH 17.05
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.2, Build 9200

Time from start: 0 hours 0 mins 22 secs
Error occurred at: 07/14/17, 11:04:27
Error description: Error BASE/1004 No exported method: FIELDS
Args:
[ 1] = U

Stack Calls
===========
Called from: => FIELDS( 0 )
Called from: .\source\function\ADOFUNCS.PRG => FWADOSTRUCT( 1747 )
Called from: .\source\function\ADOFUNCS.PRG => FW_ADOEXPORTTODBF( 1192 )
Called from: mssql01.prg => MAIN( 26 )



With the code I put before works Ok, but in the middle of the process fails. It was my question.

Any advise?

FWH 25.12

Harbour/Hbmk2

Microsoft Visual C++

MySql 8.0

Antigravity

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Pasar tablas SQL Server a DBF
Posted: Sun Jul 16, 2017 02:26 PM

En el bucle de conversi贸n, haz un if para saltarte esa base de datos, termina el resto, y fuera del bucle haz un import de esa base de datos con el par谩metro final .T. como te indica Mr Rao, para que puedas modificar o ver la estructura, a ver donde puede estar el problema ( en qu茅 campo )

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1276
Joined: Tue Dec 28, 2010 01:29 PM
Re: Pasar tablas SQL Server a DBF
Posted: Sun Jul 16, 2017 02:39 PM
Cristobal, no creo que el error sea una tabla, ya que hace el proceso de copia pero se detiene

Aqui coloco el pantallazo que me arroja

FWH 25.12

Harbour/Hbmk2

Microsoft Visual C++

MySql 8.0

Antigravity

Posts: 1276
Joined: Tue Dec 28, 2010 01:29 PM
Re: Pasar tablas SQL Server a DBF
Posted: Sun Jul 16, 2017 03:15 PM

Listo

Excluyendo la Tabla CASE se logro realizar el export exitosamente.

Ahora, existe alguna funcion que importe las DBF a Mysql?

FWH 25.12

Harbour/Hbmk2

Microsoft Visual C++

MySql 8.0

Antigravity

Posts: 1276
Joined: Tue Dec 28, 2010 01:29 PM
Re: Pasar tablas SQL Server a DBF
Posted: Sun Jul 16, 2017 03:17 PM
Compuin wrote:Listo

Excluyendo la Tabla CASE se logro realizar el export exitosamente.

Ahora, existe alguna funcion que importe las DBF a Mysql?


Ya la consegui

function FW_AdoImportFromDBF

Realizo las pruebas y os dejare saber

FWH 25.12

Harbour/Hbmk2

Microsoft Visual C++

MySql 8.0

Antigravity

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Pasar tablas SQL Server a DBF
Posted: Sun Jul 16, 2017 03:37 PM

If you are using ADO for MySql, you can use FW_AdoImportFromDBF()
If you are using FWMYSQL for connecting to MySql, you can use oCn:ImportFromDBF()

Regards



G. N. Rao.

Hyderabad, India