gente.
Como hago para que usando TMYSQL el resultado despues de hacer:
Select * from clientes
lo transfiera a un arra para poder manejarlo?
Gracias.
gente.
Como hago para que usando TMYSQL el resultado despues de hacer:
Select * from clientes
lo transfiera a un arra para poder manejarlo?
Gracias.
STATIC FUNCTION connect()
lExit := .f.
oServer := TMySQLServer():New( cHost,cUsuario,cPassword,nPuerto )
if oServer:NetErr()
Alert(oServer:Error(),"Se gener贸 error")
lExit := .t.
RETURN NIL
endif
IF !(oServer:DBExist(cDBName))
? "La base de datos no existe, avise al administrador...."
oServer:END()
lExit := .t.
RETURN NIL
ENDIF
oServer:SelectDB( cDBName )
aStruc := oServer:TableStruct( cTBName )
oQuery := oServer:Query( "SELECT * from " + cTBName )
IF oQuery:nNumRows > 0
aSample := Array( oQuery:nNumRows )
WHILE nI <= oQuery:nNumRows
aSample[ nI ] := ARRAY( oQuery:nNumFields )
oQuery:GETROW( nI )
FOR nJ := 1 TO oQuery:nNumFields
aSample[ nI ][ nJ ] := oQuery:Fieldget( nJ )
NEXT
nI++
Enddo
ELSE
aSample := {}
aCol := {}
FOR nJ := 1 TO oQuery:nNumFields
AADD(aCol," ")
NEXT
AADD(aSample,aCol)
lExit := .f.
lExit := .f.
ENDIF
RETURN NIL
//
STATIC FUNCTION arrayxBrowse( )
LOCAL oWnd,oBrw,oCol,x
//**
DEFINE WINDOW oWnd TITLE "Mostrando mysql con xBrowse"
oBrw := TXBrowse():New( oWnd )
oBrw:SetArray( aSample, .t. )
FOR x := 1 TO oQuery:nNumFields
oBrw:aCols[x]:cHeader := aStruc[x,1]
NEXT
oBrw:lHScroll := .t.
oBrw:lVScroll := .t.
oBrw:nFreeze := 1
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW
oBrw:CreateFromCode()
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd ON INIT oBrw:SetFocus()
RELEASE oWnd,oBrw,oCol,x
RETURN NILleandro wrote:Amigo creo que es lo que necesitas... este codigo me lo paso william morales hace ya un buen tiempo...
STATIC FUNCTION connect() lExit := .f. oServer := TMySQLServer():New( cHost,cUsuario,cPassword,nPuerto ) if oServer:NetErr() Alert(oServer:Error(),"Se gener贸 error") lExit := .t. RETURN NIL endif IF !(oServer:DBExist(cDBName)) ? "La base de datos no existe, avise al administrador...." oServer:END() lExit := .t. RETURN NIL ENDIF oServer:SelectDB( cDBName ) aStruc := oServer:TableStruct( cTBName ) oQuery := oServer:Query( "SELECT * from " + cTBName ) IF oQuery:nNumRows > 0 aSample := Array( oQuery:nNumRows ) WHILE nI <= oQuery:nNumRows aSample[ nI ] := ARRAY( oQuery:nNumFields ) oQuery:GETROW( nI ) FOR nJ := 1 TO oQuery:nNumFields aSample[ nI ][ nJ ] := oQuery:Fieldget( nJ ) NEXT nI++ Enddo ELSE aSample := {} aCol := {} FOR nJ := 1 TO oQuery:nNumFields AADD(aCol," ") NEXT AADD(aSample,aCol) lExit := .f. lExit := .f. ENDIF RETURN NIL // STATIC FUNCTION arrayxBrowse( ) LOCAL oWnd,oBrw,oCol,x //** DEFINE WINDOW oWnd TITLE "Mostrando mysql con xBrowse" oBrw := TXBrowse():New( oWnd ) oBrw:SetArray( aSample, .t. ) FOR x := 1 TO oQuery:nNumFields oBrw:aCols[x]:cHeader := aStruc[x,1] NEXT oBrw:lHScroll := .t. oBrw:lVScroll := .t. oBrw:nFreeze := 1 oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW oBrw:CreateFromCode() oWnd:oClient := oBrw ACTIVATE WINDOW oWnd ON INIT oBrw:SetFocus() RELEASE oWnd,oBrw,oCol,x RETURN NIL
espero te sirva
goosfancito wrote:gente.[/url]
Como hago para que usando TMYSQL el resultado despues de hacer:
Select * from clientes
lo transfiera a un arra para poder manejarlo?
Gracias.
Goos:
No tengo experiencia en el tema peroooooo, echale una mirada al metodo GetRows del recordset, creo que es lo que necesitas.
Saludos
Armando wrote:Goos:
No tengo experiencia en el tema peroooooo, echale una mirada al metodo GetRows del recordset, creo que es lo que necesitas.
Saludos