Page 2 of 4

Re: Pasar tablas SQL Server a DBF

PostPosted: Thu Jul 13, 2017 4:58 pm
by Compuin
cnavarro wrote:Intenta no cerrando el oRs:Close()


El mismo error

Can not create OCRD

Re: Pasar tablas SQL Server a DBF

PostPosted: Thu Jul 13, 2017 5:42 pm
by cnavarro
Intenta ponerle el path completo donde quieras crearlo

Re: Pasar tablas SQL Server a DBF

PostPosted: Thu Jul 13, 2017 5:45 pm
by Compuin
Tampoco

Re: Pasar tablas SQL Server a DBF

PostPosted: Thu Jul 13, 2017 7:29 pm
by Compuin
Mr Rao,

Any advise?

Re: Pasar tablas SQL Server a DBF

PostPosted: Thu Jul 13, 2017 7:35 pm
by cnavarro
Tampoco estás cerrando la conexión oCn:Close antes verdad?

Re: Pasar tablas SQL Server a DBF

PostPosted: Thu Jul 13, 2017 7:44 pm
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 ?

Re: Pasar tablas SQL Server a DBF

PostPosted: Thu Jul 13, 2017 8:28 pm
by cnavarro
No podia funcionar con la conexion cerrada

Prueba con FW_AdoTables( oCn )

Re: Pasar tablas SQL Server a DBF

PostPosted: Fri Jul 14, 2017 2:42 pm
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 ?

Re: Pasar tablas SQL Server a DBF

PostPosted: Sun Jul 16, 2017 12:07 pm
by nageswaragunupudi
Code: Select all  Expand view
#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
 

Re: Pasar tablas SQL Server a DBF

PostPosted: Sun Jul 16, 2017 1:00 pm
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 view
#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?

Re: Pasar tablas SQL Server a DBF

PostPosted: Sun Jul 16, 2017 2:26 pm
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 )

Re: Pasar tablas SQL Server a DBF

PostPosted: Sun Jul 16, 2017 2:39 pm
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

Re: Pasar tablas SQL Server a DBF

PostPosted: Sun Jul 16, 2017 3:15 pm
by Compuin
Listo

Excluyendo la Tabla CASE se logro realizar el export exitosamente.

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

Re: Pasar tablas SQL Server a DBF

PostPosted: Sun Jul 16, 2017 3:17 pm
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

Re: Pasar tablas SQL Server a DBF

PostPosted: Sun Jul 16, 2017 3:37 pm
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()