In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

ListBox - MySQL

Foro de Xailer profesional en español
Responder
Daniel Pechir
Mensajes: 191
Registrado: Vie Mar 15, 2013 12:32 am

ListBox - MySQL

Mensaje por Daniel Pechir »

HOLA A TODOS

NECESITO LLENAR UN ListBox CON LA ESTRUCTURA DE UNA TABLA MySQL

GRACIAS POR SU AYUDA

DANIEL PECHIR TAGER
martindelangel
Mensajes: 47
Registrado: Jue Mar 21, 2013 11:26 pm

Re: ListBox - MySQL

Mensaje por martindelangel »

Hola Daniel:

Teniendo una tabla de Mysql/MariaDb

tabla : tblgrupos

con 4 columnas:

GRUPO_ID,REFE,OFICINA,ACTIVA

y desea poner en un LISTBOX LA COLUMNA OFICINA ( columna 3)

LOCAL aData := {}, aDatos := {}, aGrupos:={}


aData := Appdata:cnn:QueryArray( "SELECT OFICINA From tblgrupos ORDER BY OFICINA" )

IF Len( aData ) == 0
MSGSTOP( "No Existen Registros de Oficinas Instaladas en el Sistema" )
::Close()
ENDIF

AEval( aData, {| X, N| AAdd( AAdd( aGrupos,X[ 3 ] ) } ) // x[3] coloumna 3 en la tabla que corresponde a "OFICINA"

::oListGrupo:aItems := aGrupos
::oListgrupo:Refresh()


Saludos...
Daniel Pechir
Mensajes: 191
Registrado: Vie Mar 15, 2013 12:32 am

Re: ListBox - MySQL

Mensaje por Daniel Pechir »

GRACIAS MARTIN

YO NECESITO MOSTRAR LA ESTRUCTURA EN EL LISTBOX ( NOMBRE DE LAS COLUMNAS DE LA TABLA )

DANIEL PECHIR TAGER
martindelangel
Mensajes: 47
Registrado: Jue Mar 21, 2013 11:26 pm

Re: ListBox - MySQL

Mensaje por martindelangel »

Hola Daniel:

Disculpa . no lei bien tu mensaje.

con este select obtienes los nombres de las columnas:

SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'nombre base de datos' AND TABLE_NAME = 'nombretabla'

Saludos...
Daniel Pechir
Mensajes: 191
Registrado: Vie Mar 15, 2013 12:32 am

Re: ListBox - MySQL

Mensaje por Daniel Pechir »

GRACIAS MARTIN

DIOS TE BENDICE

DANIEL
Daniel Pechir
Mensajes: 191
Registrado: Vie Mar 15, 2013 12:32 am

Re: ListBox - MySQL

Mensaje por Daniel Pechir »

PERDON MARTIN

YO MADO EL SIGUIENTE QUERY

cSelect := "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE "+;
"TABLE_SCHEMA = '"+AppData:cDataBase+"' and Table_Name = '"+cArchivo+"'"

WITH OBJECT ::oConsu
:oDataSource := AppData:oMySqlDS
:cSelect := cSelect
:nCursorType := adOpenDynamic
:nLockType := adLockOptimistic
:cProcess := 'GENERAL'
IF :lOpen
:Close()
ENDIF
IF !:lOpen
:lOpen:= .T.
IF !:lOpen
MsgStop( "ERROR: No es posible abrir el archivo", "Error de conexion.." )
RETURN NIL
ENDIF
ENDIF
:lReadOnly := .F.
END

DESPUES LO ABRO CON FAST REPORT, PERO SOLO MUESTRA UN CAMPO "COLUMN_NAME" EL CUAL ESTA VACIO

COMO OBTENDO UNA MATRIZ CON LOS NOMBRES DE LAS COLUMNAS ?

DANIEL
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5706
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

Re: ListBox - MySQL

Mensaje por jfgimenez »

Daniel Pechir escribió:COMO OBTENDO UNA MATRIZ CON LOS NOMBRES DE LAS COLUMNAS ?
Revisa la propiedad aFields del dataset. Contiene un array con todos los campos (columnas) del dataset, donde cada elemento es un objeto del tipo TDataField
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Daniel Pechir
Mensajes: 191
Registrado: Vie Mar 15, 2013 12:32 am

Re: ListBox - MySQL

Mensaje por Daniel Pechir »

YA ESTA

GRACIAS JOSE

DIOS TE BENDICE

DANIEL
Responder