Pasar tablas SQL Server a DBF

User avatar
Compuin
Posts: 1252
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada
Has thanked: 7 times
Been thanked: 3 times

Re: Pasar tablas SQL Server a DBF

Post by Compuin »

cnavarro wrote:Intenta no cerrando el oRs:Close()


El mismo error

Can not create OCRD
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: Pasar tablas SQL Server a DBF

Post by cnavarro »

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
User avatar
Compuin
Posts: 1252
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada
Has thanked: 7 times
Been thanked: 3 times

Re: Pasar tablas SQL Server a DBF

Post by Compuin »

Tampoco
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
User avatar
Compuin
Posts: 1252
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada
Has thanked: 7 times
Been thanked: 3 times

Re: Pasar tablas SQL Server a DBF

Post by Compuin »

Mr Rao,

Any advise?
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: Pasar tablas SQL Server a DBF

Post by cnavarro »

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
User avatar
Compuin
Posts: 1252
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada
Has thanked: 7 times
Been thanked: 3 times

Re: Pasar tablas SQL Server a DBF

Post by Compuin »

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 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: Pasar tablas SQL Server a DBF

Post by cnavarro »

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
User avatar
Compuin
Posts: 1252
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada
Has thanked: 7 times
Been thanked: 3 times

Re: Pasar tablas SQL Server a DBF

Post by Compuin »

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 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Pasar tablas SQL Server a DBF

Post by nageswaragunupudi »

Code: Select all | Expand

#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
User avatar
Compuin
Posts: 1252
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada
Has thanked: 7 times
Been thanked: 3 times

Re: Pasar tablas SQL Server a DBF

Post by Compuin »

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: Select all | Expand

#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 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: Pasar tablas SQL Server a DBF

Post by cnavarro »

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
User avatar
Compuin
Posts: 1252
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada
Has thanked: 7 times
Been thanked: 3 times

Re: Pasar tablas SQL Server a DBF

Post by Compuin »

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

Image
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
User avatar
Compuin
Posts: 1252
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada
Has thanked: 7 times
Been thanked: 3 times

Re: Pasar tablas SQL Server a DBF

Post by Compuin »

Listo

Excluyendo la Tabla CASE se logro realizar el export exitosamente.

Ahora, existe alguna funcion que importe las DBF a Mysql?
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
User avatar
Compuin
Posts: 1252
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada
Has thanked: 7 times
Been thanked: 3 times

Re: Pasar tablas SQL Server a DBF

Post by Compuin »

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 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Pasar tablas SQL Server a DBF

Post by nageswaragunupudi »

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
Post Reply