FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Error al insertar registro con Clase MariaD
Posts: 141
Joined: Fri Feb 15, 2019 01:37 PM
Error al insertar registro con Clase MariaD
Posted: Sat Feb 16, 2019 11:43 PM

Estoy practicando la Clase MariaD, la conexion y el browse hasta ahi todo bien.
Modifico, elimino registro bien. El problema se presenta cuando estoy adicionando un registro.
Cambio la estructura de los campos que estan en Null a Not Null tampoco.
Asi:

IF lNuevo
  oRsResolu:AddNew()
ENDIF
oRsResolu:Fields("CODIGO"):value  :=oUni:vCodigo-------->AQUI GRABA BIEN  ESTE CAMPO
oRsResolu:Fields("NOMIP01"):value :=oUni:vPropie----------> ERROR EN ESTA LINEA

//----------------------------------------
ESTRUCTURA DE LA TABLA
//----------------------------------------

FieldTypeComment
CODIGO varchar(21) NOT NULL
NOMIP01 varchar(33) NULL
TIPIP01 varchar(1) NULL
IDEIP01 double NULL
DIRIP01 varchar(34) NULL
SUPIP01 decimal(8,0)NULL
AREIP01 decimal(8,0)NULL
CONIP01 decimal(8,0)NULL
DESTINO varchar(2) NULL
RESOLU varchar(17) NULL

ERROR PRESENTADO
//----------------------------------------
Error description: Error BASE/1005 Class: 'NIL' has no property: VALUE
Args:
[ 1] = U
[ 2] = C GKDFÑGKFDÑÑLDSFG

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error al insertar registro con Clase MariaD
Posted: Sun Feb 17, 2019 10:37 AM

Are you using ADO or FWH built-in MariaDB class?
In either case, the field name must have been wrongly spelled.

Regards



G. N. Rao.

Hyderabad, India
Posts: 141
Joined: Fri Feb 15, 2019 01:37 PM
Re: Error al insertar registro con Clase MariaD
Posted: Tue Feb 19, 2019 12:07 AM

Gracias por contestar.

Estoy utilizando FWH incorporado en la clase MariaDB?
Revise los ejemplos que hay en sample de maria01......maria16.
Y los soluciones asi:

include "FiveWin.ch"

STATIC oRs,oCn
//------------------------------
function Main()
//------------------------------
local oRs, cTable, oBrw, oList, oDlg, cFile,oFont,oBar
local cServer := "127.0.0.1"
local cDataBase := "Santana"
local cUser := "root"
local cPassWord := "19585287"
local nPort := 3307
local nFlags := 0
local oCn := NIL

if oCn == nil .or. oCn:Ping() = .F. 
  MsgRun( "Connecting to Server", "CLOUD SERVER", ;
  { || oCn   := maria_Connect(  {cServer, cDataBase, cUser, cPassWord, nPort } ) } )    
endif

if oCn == nil
  ? "Fallo la Conexion"
  return nil
else
   ? "Conexion Exitosa"
endif

cFile = "catastro"
oRs := oCn:RowSet( cFile ) // Get fields from table

DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 1050,500 PIXEL FONT oFont TITLE cFile;
GRADIENT {{ .5, CLR_BLUE, RGB(202,202,255) }, { .5, RGB(202,202,255), CLR_BLUE }}
oDlg:lHelpIcon := .f.

DEFINE BUTTONBAR oBar OF oDlg SIZE 70, 70 2010

DEFINE BUTTON OF oBar ACTION Nuevocatas(oBrw,.T.,oRs);
FILENAME "C:\fwh18.12\bitmaps\32x32\new.bmp" PROMPT "Nuevo" TOOLTIP "Nuevo"
DEFINE BUTTON OF oBar ACTION Nuevocatas(oBrw,.F.,oRs);
FILENAME "C:\fwh18.12\bitmaps\32x32\edit.bmp" PROMPT "Editar" ;
TOOLTIP "Editar"
DEFINE BUTTON OF oBar action( oDlg:End()) ;
FILENAME "C:\fwh18.12\bitmaps\32x32\exit.bmp" PROMPT "Salir" TOOLTIP "Salir de la Ventana"

@ 3,2 XBROWSE oBrw OF oDlg SIZE 500,200 ;
DATASOURCE oRs AUTOCOLS ;
CELL LINES FOOTERS NOBORDER FASTEDIT

oBrw:nStretchCol := STRETCHCOL_LAST
WITH OBJECT oBrw
:bRecSeldata := { || oBrw:KeyNo }
:nRecSelWidth := "999,999"
:bRecSelFooter := { || oBrw:nLen }
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:nRowDividerStyle := LINESTYLE_LIGHTGRAY
:nMarqueeStyle := MARQSTYLE_HIGHLROWMS
:bClrRowFocus := { || { CLR_BLACK, RGB(185,220,255) } }
:blDblClick := { | nRow, nCol, nKey | Nuevocatas(oBrw,.T.,oRs)}
:bClrEdits := { || { CLR_BLACK, CLR_YELLOW }}
:bClrRowFocus := { || { CLR_BLACK, RGB(185,220,255) } }
:l2007 := .t.
:CreateFromCode()
END

ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
oCn:Close()
return nil

//---------------------------------------------------------//
static function Nuevocatas( oBrw, lNuevo,oRs )
//---------------------------------------------------------//
local oDlg,lSalvar := .f.,vcodigo:=space(21),vnombre:=space(33)
local lSaved := .f.

IF lNuevo
oRs:AddNew()
ENDIF

DEFINE DIALOG oDlg SIZE 500,210 PIXEL ;
TITLE "Prueba de la Clase Fwh mariadb"
oDlg:lHelpIcon := .f.

@ 20, 20 SAY "Codigo" SIZE 50,12 PIXEL OF oDlg
@ 20, 80 GET oRs:Codigo SIZE 100,12 PIXEL OF oDlg PICTURE "@#"
@ 40, 20 SAY "Nombre" SIZE 50,12 PIXEL OF oDlg
@ 40, 80 GET oRs:nomip01 SIZE 150,12 PIXEL OF oDlg PICTURE "@!"
*

@ 80, 20 BUTTON "Save" SIZE 40,15 PIXEL OF oDlg ;
ACTION ( lSalvar := .T. , oDlg:End() )

@ 80, 80 BUTTON "Cancel" SIZE 40,15 PIXEL OF oDlg ACTION oDlg:End()

ACTIVATE DIALOG oDlg CENTER

IF lSalvar
msginfo("salvando")
msginfo(oRs:codigo,oRs:nomip01)
oRs:Save()
oRs:Refresh()
oRs:ReQuery()
oBrw:Refresh() // Repintamos el ListBox
ENDIF

RETURN(.T.)

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error al insertar registro con Clase MariaD
Posted: Tue Feb 19, 2019 02:34 AM
We recommend editing records this way:
Code (fw): Select all Collapse
#include "FiveWin.ch"

STATIC oRs,oCn 
//------------------------------
function Main()
//------------------------------
   local oRs, cTable, oBrw, oList, oDlg, cFile,oFont,oBar
   local cServer := "127.0.0.1"
   local cDataBase := "Santana"
   local cUser := "root"
   local cPassWord := "19585287"
   local nPort := 3307
   local nFlags := 0

   MsgRun( "Connecting to Server", "CLOUD SERVER", ;
      { || oCn := maria_Connect( {cServer, cDataBase, cUser, cPassWord, nPort } ) } ) 

   if oCn == nil
      ? "Fallo la Conexion"
      return nil
   else
      ? "Conexion Exitosa"
   endif

   cFile = "catastro" 
   oRs := oCn:RowSet( cFile ) // Get fields from table
   oRs:bEdit   := { |oRec| EditCatastro( oRec ) }
   
   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 1050,500 PIXEL FONT oFont TITLE cFile;
      GRADIENT {{ .5, CLR_BLUE, RGB(202,202,255) }, { .5, RGB(202,202,255), CLR_BLUE }}
      oDlg:lHelpIcon := .f.

   DEFINE BUTTONBAR oBar OF oDlg SIZE 70, 70 2010

   DEFINE BUTTON OF oBar ACTION oBrw:EditSource( .t. ) ;
      FILENAME "C:\fwh18.12\bitmaps\32x32\new.bmp" PROMPT "Nuevo" TOOLTIP "Nuevo"
   DEFINE BUTTON OF oBar ACTION oBrw:EditSource() ;
      FILENAME "C:\fwh18.12\bitmaps\32x32\edit.bmp" PROMPT "Editar" ;
      TOOLTIP "Editar"
   DEFINE BUTTON OF oBar action( oDlg:End()) ;
      FILENAME "C:\fwh18.12\bitmaps\32x32\exit.bmp" PROMPT "Salir" TOOLTIP "Salir de la Ventana"

   @ 3,2 XBROWSE oBrw OF oDlg SIZE 500,200 ;
      DATASOURCE oRs AUTOCOLS ;
      CELL LINES FOOTERS NOBORDER FASTEDIT

   oBrw:nStretchCol := STRETCHCOL_LAST
   WITH OBJECT oBrw
      :bRecSeldata := { || oBrw:KeyNo }
      :nRecSelWidth := "999,999"
      :bRecSelFooter := { || oBrw:nLen }
      :nColDividerStyle := LINESTYLE_LIGHTGRAY
      :nRowDividerStyle := LINESTYLE_LIGHTGRAY
      :nMarqueeStyle := MARQSTYLE_HIGHLROWMS
      :bClrRowFocus := { || { CLR_BLACK, RGB(185,220,255) } }
      :blDblClick := { | nRow, nCol, nKey | Nuevocatas(oBrw,.T.,oRs)}
      :bClrEdits := { || { CLR_BLACK, CLR_YELLOW }}
      :bClrRowFocus := { || { CLR_BLACK, RGB(185,220,255) } }
      :l2007 := .t.
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE FONT oFont
   oCn:Close()

return nil


static function EditCatastro( oRec )

   local lNew     := ( oRec:RecNo == 0 )
   local oDlg
   
   DEFINE DIALOG oDlg SIZE 500,210 PIXEL ;
      TITLE "Prueba de la Clase Fwh mariadb"
   oDlg:lHelpIcon := .f.
   
   @ 20, 20 SAY "Codigo" SIZE 50,12 PIXEL OF oDlg
   @ 20, 80 GET oRs:Codigo SIZE 100,12 PIXEL OF oDlg PICTURE "@#"
   @ 40, 20 SAY "Nombre" SIZE 50,12 PIXEL OF oDlg
   @ 40, 80 GET oRs:nomip01 SIZE 150,12 PIXEL OF oDlg PICTURE "@!"

   @ 80, 20 BUTTON "Save" SIZE 40,15 PIXEL OF oDlg ;
      ACTION ( oRec:Save(), oDlg:End() )

   @ 80, 80 BUTTON "Cancel" SIZE 40,15 PIXEL OF oDlg ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTER 

return nil


Please try this and ask us for any clarifications.
Regards



G. N. Rao.

Hyderabad, India
Posts: 141
Joined: Fri Feb 15, 2019 01:37 PM
Re: Error al insertar registro con Clase MariaD
Posted: Wed Feb 20, 2019 01:22 PM

Ok Gracias

Por toda la colaboracion, como seria para tener un pequeño manual o un tutorial de la Clase. Necesito un ejemplo de convertir tabla del servidor Mysql a dbf.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error al insertar registro con Clase MariaD
Posted: Wed Feb 20, 2019 03:47 PM
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error al insertar registro con Clase MariaD
Posted: Wed Feb 20, 2019 03:57 PM
DBF to MySql
Code (fw): Select all Collapse
oCn:ImportFromDBF( cDbf )


MySql query to DBF
Code (fw): Select all Collapse
oCn:SaveToDBF( cSqlQuery, cDbf )
// example
oCn:SaveToDBF( "select * from customer", "c:\myfolder\cust.dbf" )
Regards



G. N. Rao.

Hyderabad, India
Posts: 141
Joined: Fri Feb 15, 2019 01:37 PM
Re: Error al insertar registro con Clase MariaD
Posted: Thu Feb 21, 2019 01:48 AM

Gracias.

Excelente, esto es lo que estoy necesitando, para seguir adelante con la Clase.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error al insertar registro con Clase MariaD
Posted: Thu Feb 21, 2019 04:35 AM

Please keep posting your initial work.
That helps us to advise simpler and better ways of doing the same thing.

Regards



G. N. Rao.

Hyderabad, India
Posts: 141
Joined: Fri Feb 15, 2019 01:37 PM
Re: Error al insertar registro con Clase MariaD
Posted: Thu Feb 21, 2019 01:32 PM

Nuevamente Gracias
Soy nuevo en esto, el cambio de utilizar DBF a Sql, no es facil. Pero hay voy.
Tengo una duda en esta linea.

oRs:bEdit := { |oRec| EditCatastro( oRec ) }
oRec nos da la posicion del registro en el ORs

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error al insertar registro con Clase MariaD
Posted: Thu Feb 21, 2019 01:37 PM

oRec is the Record Object of the current row.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion