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.

Usage of TDataSet

Xailer professional forum in English
Milan Mehta
Posts: 111
Joined: Sun Dec 27, 2009 9:54 am

Usage of TDataSet

Postby Milan Mehta » Wed Nov 23, 2016 3:23 pm

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.
User avatar
ignacio
Site Admin
Posts: 8550
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

Re: Usage of TDataSet

Postby ignacio » Wed Nov 23, 2016 4:17 pm

Hello,

Please send at least the error.log. TIA.

Regards,

Note: Use TSqlQuery or TSqlTable instead of TDataset
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Milan Mehta
Posts: 111
Joined: Sun Dec 27, 2009 9:54 am

Re: Usage of TDataSet

Postby Milan Mehta » Thu Nov 24, 2016 8:07 am

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[i]:cName) + ':' + HB_ValToExp(aTabFields[i]:lPrimaryKey))
NEXT

Kindly guide.

TIA
Milan.
User avatar
ignacio
Site Admin
Posts: 8550
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

Re: Usage of TDataSet

Postby ignacio » Thu Nov 24, 2016 11:03 am

Please send the table definition (DDL). TIA.

Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Milan Mehta
Posts: 111
Joined: Sun Dec 27, 2009 9:54 am

Re: Usage of TDataSet

Postby Milan Mehta » Sat Nov 26, 2016 3:07 pm

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
;
User avatar
ignacio
Site Admin
Posts: 8550
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

Re: Usage of TDataSet

Postby ignacio » Mon Nov 28, 2016 11:38 am

Tested and working correctly. This is the code used:

Code: Select all

   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,
Attachments
mysql.zip
(2.25 KiB) Downloaded 66 times
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Milan Mehta
Posts: 111
Joined: Sun Dec 27, 2009 9:54 am

Re: Usage of TDataSet

Postby Milan Mehta » Tue Nov 29, 2016 11:15 am

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.
User avatar
ignacio
Site Admin
Posts: 8550
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

Re: Usage of TDataSet

Postby ignacio » Tue Nov 29, 2016 12:01 pm

Send mi your project and I send you the EXE file.

Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info

Return to “English”