error con adoimportfromdbf

error con adoimportfromdbf

Postby artu01 » Fri Aug 21, 2020 10:20 pm

Mr. Rao
Estoy importando mi tabla mcodi.dbf a MSSQL de esta forma:
Code: Select all  Expand view

  xPROVIDER := "SQLOLEDB"              
  xSOURCE   := "WIN-JET3FF08IIT"                
  xPASSWORD := "Pysa2019.
  xCATALOG  := "
PysaBD"                
  xUSERID   := "
sa"
  xConnect  := 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xCATALOG+';User Id='+xUSERID+';Password='+xPASSWORD

  TRY
    oConnect:= CreateObject( "
ADODB.Connection" )
    oConnect:Open( xConnect )
  CATCH oError
     MsgStop( oError:Description )
  END

    TRY
        oConnect:Execute( "
DROP TABLE MCODI" )
    CATCH
    END
    FW_adoimportfromdbf(oConnect, "
Z:\B1\MCODI.DBF")


Son 14942 registros por importar pero solo importa los primeros 12200 registros y alli me sale esta pantalla
Image
Adjunto link del dbf
https://we.tl/t-mkoKwPC2tU
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
artu01
 
Posts: 400
Joined: Fri May 11, 2007 8:20 pm
Location: Lima

Re: error con adoimportfromdbf

Postby nageswaragunupudi » Sat Aug 22, 2020 2:10 pm

This worked for me without any errors and should work for you also.
Code: Select all  Expand view
  oCn := FW_OpenAdoConnection( { "MSSQL", xSource, xCatalog, xUserID, xPassword }, .t. )
   if oCn == nil
      ? "connect fail"
      return nil
   endif
   ? "Connected"
   MsgRun( "Importing MCODI.DBF", "MSSQL", { || lOk := FW_AdoImportFromDBF( oCn, "MCODI\MCODI.DBF" ) } )
   if lOk
      oRs   := FW_OpenRecordSet( oCn, "MCODI" )
      XBROWSER oRs TITLE oRs:Source SHOW RECID
      oRs:Close()
   endif
   oCn:Close()
 

Please use the function FW_OpenAdoConnection(...) as above instead of directly connecting.

Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10619
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: error con adoimportfromdbf

Postby artu01 » Sat Aug 22, 2020 4:47 pm

Mr. rao, thank you, i'll try your recommendation
Another question, seeing the table that you imported, i notice the column id but my dbf doesn't have that field?


Excellent photo of the penguin seeing the camera!
nageswaragunupudi wrote:This worked for me without any errors and should work for you also.
Code: Select all  Expand view
  oCn := FW_OpenAdoConnection( { "MSSQL", xSource, xCatalog, xUserID, xPassword }, .t. )
   if oCn == nil
      ? "connect fail"
      return nil
   endif
   ? "Connected"
   MsgRun( "Importing MCODI.DBF", "MSSQL", { || lOk := FW_AdoImportFromDBF( oCn, "MCODI\MCODI.DBF" ) } )
   if lOk
      oRs   := FW_OpenRecordSet( oCn, "MCODI" )
      XBROWSER oRs TITLE oRs:Source SHOW RECID
      oRs:Close()
   endif
   oCn:Close()
 

Please use the function FW_OpenAdoConnection(...) as above instead of directly connecting.

Image
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
artu01
 
Posts: 400
Joined: Fri May 11, 2007 8:20 pm
Location: Lima

Re: error con adoimportfromdbf

Postby nageswaragunupudi » Sun Aug 23, 2020 3:16 am

By default, the function adds an autoincrement field ID as the primary key, if the DBF does not already have an auto-inc field.

Many a time we forget or ignore that is essential to have a primary key when we migrate to SQL databases and this feature simplifies the process of migration.

Still, we can override by specifying one of the other existing fields as the primary key.

But never, never create a table in any sql database without a primary key.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10619
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: error con adoimportfromdbf

Postby artu01 » Sun Aug 23, 2020 3:44 am

nageswaragunupudi wrote:Still, we can override by specifying one of the other existing fields as the primary key.

Mr. Rao :
Into the importation How specify an field as the primary key ?

Thank you Master for your response
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
artu01
 
Posts: 400
Joined: Fri May 11, 2007 8:20 pm
Location: Lima


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 36 guests