Error al insertar registro con Clase MariaD

Error al insertar registro con Clase MariaD

Postby Adolfredo Martinez » 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
Adolfredo Martinez
 
Posts: 116
Joined: Fri Feb 15, 2019 1:37 pm
Location: Aracataca-Colombia

Re: Error al insertar registro con Clase MariaD

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Error al insertar registro con Clase MariaD

Postby Adolfredo Martinez » 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.)
Adolfredo Martinez
 
Posts: 116
Joined: Fri Feb 15, 2019 1:37 pm
Location: Aracataca-Colombia

Re: Error al insertar registro con Clase MariaD

Postby nageswaragunupudi » Tue Feb 19, 2019 2:34 am

We recommend editing records this way:
Code: Select all  Expand view  RUN
#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
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Error al insertar registro con Clase MariaD

Postby Adolfredo Martinez » Wed Feb 20, 2019 1: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.
Adolfredo Martinez
 
Posts: 116
Joined: Fri Feb 15, 2019 1:37 pm
Location: Aracataca-Colombia

Re: Error al insertar registro con Clase MariaD

Postby nageswaragunupudi » Wed Feb 20, 2019 3:47 pm

Regards

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

Re: Error al insertar registro con Clase MariaD

Postby nageswaragunupudi » Wed Feb 20, 2019 3:57 pm

DBF to MySql
Code: Select all  Expand view  RUN
oCn:ImportFromDBF( cDbf )


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

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

Re: Error al insertar registro con Clase MariaD

Postby Adolfredo Martinez » Thu Feb 21, 2019 1:48 am

Gracias.

Excelente, esto es lo que estoy necesitando, para seguir adelante con la Clase.
Adolfredo Martinez
 
Posts: 116
Joined: Fri Feb 15, 2019 1:37 pm
Location: Aracataca-Colombia

Re: Error al insertar registro con Clase MariaD

Postby nageswaragunupudi » Thu Feb 21, 2019 4: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
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Error al insertar registro con Clase MariaD

Postby Adolfredo Martinez » Thu Feb 21, 2019 1: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
Adolfredo Martinez
 
Posts: 116
Joined: Fri Feb 15, 2019 1:37 pm
Location: Aracataca-Colombia

Re: Error al insertar registro con Clase MariaD

Postby nageswaragunupudi » Thu Feb 21, 2019 1:37 pm

oRec is the Record Object of the current row.
Regards

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


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], wmormar and 69 guests