Mysql recover values usaing field names

Mysql recover values usaing field names

Postby PAUL SIMM » Mon Nov 18, 2024 6:08 pm

How can I recover values from a SELECT using the field name and not its position in th array?

oCn :=maria_Connect( cHost,cUser,cDb,cPwd )

IF oCn=NIL
msgwait("Error conectando con eventos en la nube","")
return nil
ENDIF

cQwery:="SELECT * FROM proforma"
oRs := oCn:RowSet( cQwery)
MSGINFO(oRs:FieldGet(5)) //WORKS SHOWS CONTENT OF 1ST FIELD DESCRIP
MSGINFO(oRs:FieldName("DESCRIP")) //DOSE NOT WORK

oCn:Close()

RETURN NIL
****************************************************************************************
/*
CREATE TABLE `proforma` (
`UPDATED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`ID` int(6) NOT NULL AUTO_INCREMENT,
`NO_PEDIDO` int(13) DEFAULT NULL,
`UNIDADES` int(4) DEFAULT NULL,
`DESCRIP` varchar(50) DEFAULT NULL,
`VAL_UNI` float(9,2) DEFAULT NULL,
`VAL_TOT` float(9,2) DEFAULT NULL,
`DIVISA` varchar(3) DEFAULT NULL,
`FECHA` date DEFAULT NULL,
`CATEGORIA` int(6) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=62706502 DEFAULT CHARSET=latin1;
*/
Regards/Saludos
Paul

paul@pes-systems.net
User avatar
PAUL SIMM
 
Posts: 85
Joined: Fri Oct 07, 2005 7:59 am
Location: Madrid, Spain

Re: Mysql recover values usaing field names

Postby nageswaragunupudi » Mon Nov 18, 2024 7:01 pm

Code: Select all  Expand view
? oRs:FieldGet( 5 )  // works
? oRs:DESCRIP  // works. Case not sensitive
? oRs:Fields( "DESCRIP" ):Value // works. Ado syntax compatible
 
Regards

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

Re: Mysql recover values usaing field names

Postby PAUL SIMM » Thu Nov 21, 2024 9:42 am

I found oRs:DESCRIP Works
Regards/Saludos
Paul

paul@pes-systems.net
User avatar
PAUL SIMM
 
Posts: 85
Joined: Fri Oct 07, 2005 7:59 am
Location: Madrid, Spain

Re: Mysql recover values usaing field names

Postby nageswaragunupudi » Thu Nov 21, 2024 11:35 am

for modifying and editing you can use:
Code: Select all  Expand view
oRs:descript := cNewValue
oRs:fetcha := date()
// .....
oRs:Save()
Regards

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 65 guests