Página 1 de 1

Usage of TDataSet

Publicado: Mié Nov 23, 2016 3:23 pm
por Milan Mehta
I am using MariaDB Data Source.
My following code do not work and gives me error at cName Property assignment.

WITH OBJECT oTable := TDataSet():Create()
:oDataSource := AppData:oDS
:cName := 'exppcinv'
:lOpen := .T.
aTabFields := oTable:aFields
:lOpen := .F.
END WITH

What am I doing wrong ?

TIA
Milan.

Re: Usage of TDataSet

Publicado: Mié Nov 23, 2016 4:17 pm
por ignacio
Hello,

Please send at least the error.log. TIA.

Regards,

Note: Use TSqlQuery or TSqlTable instead of TDataset

Re: Usage of TDataSet

Publicado: Jue Nov 24, 2016 8:07 am
por Milan Mehta
Ok. I tried following code. However it always returns lPrimaryKey as .F. even in case of Primary Key field. I use MariaDB database.

WITH OBJECT oTable := TSqlTable():Create()
:oDataSource := AppData:oDS
:cTableName := 'exppcinv'
:lOpen := .T.
aTabFields := oTable:aFields
END WITH

FOR i = 1 TO Len(aTabFields)
MsgInfo (HB_ValToExp(aTabFields:cName) + ':' + HB_ValToExp(aTabFields:lPrimaryKey))
NEXT

Kindly guide.

TIA
Milan.

Re: Usage of TDataSet

Publicado: Jue Nov 24, 2016 11:03 am
por ignacio
Please send the table definition (DDL). TIA.

Regards,

Re: Usage of TDataSet

Publicado: Sab Nov 26, 2016 3:07 pm
por Milan Mehta
Here is DDL :

CREATE TABLE `exppcinv` (
`exppcinvbook` CHAR(2) NOT NULL,
`exppcinvexunitcode` SMALLINT(5) UNSIGNED NOT NULL,
`exppcinvvno` SMALLINT(5) UNSIGNED NOT NULL,
`vdate` DATE NOT NULL,
`party` SMALLINT(5) UNSIGNED NULL DEFAULT NULL,
`buyer` SMALLINT(5) UNSIGNED NULL DEFAULT NULL,
`buyerlcno` VARCHAR(50) NULL DEFAULT NULL,
`lcissuedt` DATE NULL DEFAULT NULL,
`lcbank` VARCHAR(50) NULL DEFAULT NULL,
`availrem` VARCHAR(500) NULL DEFAULT NULL,
`containerrem` VARCHAR(500) NULL DEFAULT NULL,
`deliveryterms` VARCHAR(50) NULL DEFAULT NULL,
`payterms` VARCHAR(50) NULL DEFAULT NULL,
`destination` VARCHAR(50) NULL DEFAULT NULL,
`carriage` VARCHAR(50) NULL DEFAULT NULL,
`receipt` VARCHAR(50) NULL DEFAULT NULL,
`transporter` VARCHAR(50) NULL DEFAULT NULL,
`discharge` VARCHAR(50) NULL DEFAULT NULL,
`lading` VARCHAR(50) NULL DEFAULT NULL,
`finaldestination` VARCHAR(50) NULL DEFAULT NULL,
`amount` DECIMAL(12,2) NOT NULL DEFAULT '0.00',
`frghtamt` DECIMAL(12,2) NOT NULL DEFAULT '0.00',
`billamt` DECIMAL(12,2) NOT NULL DEFAULT '0.00',
`noofpallets` SMALLINT(5) NOT NULL DEFAULT '0',
`palletswt` DECIMAL(12,2) NOT NULL DEFAULT '0.00',
`remarks` VARCHAR(500) NULL DEFAULT NULL,
`entryuser` SMALLINT(5) UNSIGNED NOT NULL,
`edituser` SMALLINT(5) UNSIGNED NULL DEFAULT NULL,
PRIMARY KEY (`exppcinvbook`, `exppcinvexunitcode`, `exppcinvvno`),
INDEX `FK_exppcinv_exunit` (`exppcinvexunitcode`),
INDEX `FK_exppcinv_user` (`entryuser`),
INDEX `FK_exppcinv_user_2` (`edituser`),
INDEX `FK_exppcinv_acmast` (`party`),
INDEX `FK_exppcinv_acmast_2` (`buyer`),
CONSTRAINT `FK_exppcinv_acmast` FOREIGN KEY (`party`) REFERENCES `acmast` (`accode`) ON UPDATE CASCADE,
CONSTRAINT `FK_exppcinv_acmast_2` FOREIGN KEY (`buyer`) REFERENCES `acmast` (`accode`) ON UPDATE CASCADE,
CONSTRAINT `FK_exppcinv_exunit` FOREIGN KEY (`exppcinvexunitcode`) REFERENCES `exunit` (`exunitcode`) ON UPDATE CASCADE,
CONSTRAINT `FK_exppcinv_user` FOREIGN KEY (`entryuser`) REFERENCES `user` (`usercode`) ON UPDATE CASCADE,
CONSTRAINT `FK_exppcinv_user_2` FOREIGN KEY (`edituser`) REFERENCES `user` (`usercode`) ON UPDATE CASCADE
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
;

Re: Usage of TDataSet

Publicado: Lun Nov 28, 2016 11:38 am
por ignacio
Tested and working correctly. This is the code used:

Código: Seleccionar todo

   LOCAL oField AS CLASS TDataField

   FOR EACH oField IN ::oSQLTable1:aFields
      LogDebug( oField:cName, oField:lPrimaryKey )
   NEXT
And this is the output:

#1: exppcinvbook .T.
#2: exppcinvexunitcode .T.
#3: exppcinvvno .T.
#4: vdate .F.
#5: party .F.
#6: buyer .F.
#7: buyerlcno .F.
#8: lcissuedt .F.
#9: lcbank .F.
#10: availrem .F.
#11: containerrem .F.
#12: deliveryterms .F.
#13: payterms .F.
#14: destination .F.
#15: carriage .F.
#16: receipt .F.
#17: transporter .F.
#18: discharge .F.
#19: lading .F.
#20: finaldestination .F.
#21: amount .F.
#22: frghtamt .F.
#23: billamt .F.
#24: noofpallets .F.
#25: palletswt .F.
#26: remarks .F.
#27: entryuser .F.
#28: edituser .F.

I attach the project.

Regards,

Re: Usage of TDataSet

Publicado: Mar Nov 29, 2016 11:15 am
por Milan Mehta
I tested your project. But it still do not show Primary Keys.
My Xailer is 4.0.2 (June 2015).
Should I check anything else ?

TIA
Milan.

Re: Usage of TDataSet

Publicado: Mar Nov 29, 2016 12:01 pm
por ignacio
Send mi your project and I send you the EXE file.

Regards,