Search found 31 matches

by davor.TCS
Wed 28 Sep 2022 11:56
Forum: MySQL Data Access Components
Topic: Remove and create new field at runtime
Replies: 0
Views: 116267

Remove and create new field at runtime

How to in runtime remove existing field from TMyTable and then add another (Integer) field?
I tried this but I get error "Field 'OperaterID' not found.";

Code: Select all

procedure DM.CreateNewField;
begin
  MyTable.Fields.Remove(MyTableOperater);
  MyTable.FieldDefs.Add('OperaterID', ftInteger);
  MyTable.Fields.Add(MyTable.FieldByName('OperaterID'));
  
  MyTable.Open;
end;
by davor.TCS
Sun 23 Jan 2022 09:28
Forum: SQLite Data Access Components
Topic: Saving time with . as separator 2
Replies: 5
Views: 34667

Re: Saving time with . as separator 2

Hello, I have received yours reply (but it went to spam) so today I have sent you a new email. Please, take care to set testing environment in yours Windows according to problem.
by davor.TCS
Tue 11 Jan 2022 17:44
Forum: SQLite Data Access Components
Topic: Saving time with . as separator 2
Replies: 5
Views: 34667

Re: Saving time with . as separator 2

No problem, I have sent you a small project, but be advised. To view problem, you must save Now value and then restart application.
If I created "now" value record as 18.37.43, next time when I run app it will be shown as 18.37.00.
by davor.TCS
Wed 15 Dec 2021 12:18
Forum: SQLite Data Access Components
Topic: Saving time with . as separator 2
Replies: 5
Views: 34667

Saving time with . as separator 2

Hello,

Regarding post: viewtopic.php?f=48&t=30436
I have updated SQLite to latest version 5.0.2.
If time on Windows/Android is set to hh.nn.ss with . as separator, minutes and seconds are 0.

I have used as advised:

Code: Select all

var
  FS: TFormatSettings;
begin
  FS:= TFormatSettings.Create;
  if FS.TimeSeparator = '.' then LiteConn.Options.TimeFormat:='hh.nn.ss';
  ...
end;
but then I get minutes resolved but seconds are now 0? Like it is some Short/Long Time Format issue?

Best regards
by davor.TCS
Tue 13 Jul 2021 06:13
Forum: MySQL Data Access Components
Topic: TDump image
Replies: 5
Views: 16482

Re: TDump image

Curently I have enabled HexBlob, fields with text altered to be mediumtext (fields for images retained as blob definitions), and all works fine. Will need some time to test this.

What if I import with TDump file that has blob data in Hex? Do I need to have DM.QryDump.Options.HexBlob:=True; or TDump checks this automatically?
by davor.TCS
Fri 25 Jun 2021 15:41
Forum: MySQL Data Access Components
Topic: TDump image
Replies: 5
Views: 16482

Re: TDump image

I use next procedure for import (*.sql file is compressed)

Code: Select all

procedure ImportDB;
var
MyZipFile: TZipFile;
DataStream: TMemoryStream;
MyByteData: TBytes;
begin
  if OpenDlg.Execute then
    begin
      DataStream:=TMemoryStream.Create;
      MyZipFile:=TZipFile.Create;
      try
        if MyZipFile.IsValid(OpenDlg.FileName) then
          begin
            MyZipFile.Open(OpenDlg.FileName, zmRead);
            if (MyZipFile.FileCount = 1) then
              begin
                MyZipFile.Read(0, MyByteData);
                DataStream.WriteBuffer(MyByteData[0], Length(MyByteData));
                //DM.QryDump.Options.HexBlob:=True;
                DM.QryDump.RestoreFromStream(DataStream);
              end;
            MyZipFile.Close;
          end;
      finally
        DataStream.Free;
        MyZipFile.Free;
      end;
    end;
end;
Field to store image is BLOB type field (mediumblob). Perhaps it is not possible to import it like this in TMemoryStream? Perhaps TStringStream with UTF8 is more appropriate?
by davor.TCS
Thu 03 Jun 2021 17:50
Forum: MySQL Data Access Components
Topic: TDump image
Replies: 5
Views: 16482

TDump image

In my DB image is saved to a blob field. If I export an image and then import it, sometimes I get wrong data and the image is not shown or an exception occurs. What is the best way to export image to *.sql file?
If I use HexBlob option in TDump, all is ok, but I have fields in DB that are blob fields and contain text that I don't want to export as hex.
Is it possible to do:
If image then
DoHex
else
DoRegular
regarding a column data?
Or perhaps to use TEXT field type for data that are strings?
by davor.TCS
Wed 13 Jan 2021 11:52
Forum: MySQL Data Access Components
Topic: Get OUT Param with TMyCommand
Replies: 7
Views: 5868

Re: Get OUT Param with TMyCommand

Thank you and @davidmarcus for responces, I finally used TMyQuery with defined field MyRecNo as Float.

In TMyQuery as SQL now I have this:
SELECT SUM(table_count.MyNumber) AS TblRecNo
FROM
(SELECT COUNT(*) AS MyNumber FROM &TblName1 UNION ALL SELECT COUNT(*) AS MyNumber FROM &TblName2 ) table_count;
In Delphi now I have (DM.GetRecCount is now TMyQuery):
DM.GetRecCount.MacroByName('TblName1').Value:='EventsTbl'; //<- if you do AsString it will be quoted!
DM.GetRecCount.MacroByName('TblName2').Value:='ChangedEventsTbl';
DM.GetRecCount.Execute;
ShowMessage(DM.GetRecCount.FieldByName('TblRecNo').AsString);
by davor.TCS
Sat 09 Jan 2021 15:57
Forum: MySQL Data Access Components
Topic: Get OUT Param with TMyCommand
Replies: 7
Views: 5868

Re: Get OUT Param with TMyCommand

Thank you for answer, but this does not solve my question on how to get OUT param with TMyCommand.
by davor.TCS
Fri 08 Jan 2021 12:20
Forum: MySQL Data Access Components
Topic: Get OUT Param with TMyCommand
Replies: 7
Views: 5868

Re: Get OUT Param with TMyCommand

TMyCommand does not have FieldByName property...
Params are usually set with :ParamName ...
by davor.TCS
Wed 06 Jan 2021 21:29
Forum: MySQL Data Access Components
Topic: Get OUT Param with TMyCommand
Replies: 7
Views: 5868

Get OUT Param with TMyCommand

I am using TMyComand with two IN parameters, but I can not get result into OUT parameter. How can I do this?

In TMyCommand as SQL I have this:
SELECT SUM(table_count.MyNumber) INTO @TblRecNo
FROM
(SELECT COUNT(*) AS MyNumber FROM :TblName1 UNION ALL SELECT COUNT(*) AS MyNumber FROM :TblName2) table_count;

-- this does not work
SELECT @TblRecNo INTO :TotalCount;
-- or
SET :TotalCount = @TblRecNo;
In Delphi I have something like this (DM.GetRecCount is TMyCommand):
begin
DM.GetRecCount.ParamByName('TblName1').AsString:='EventsTbl';
DM.GetRecCount.ParamByName('TblName2').AsString:='ChangedEventsTbl';
DM.GetRecCount.Execute;
ShowMessage(IntToStr(DM.GetRecCount.ParamByName('TotalCount').AsInteger));
end;
by davor.TCS
Sat 18 Apr 2020 16:30
Forum: MySQL Data Access Components
Topic: MyCommand
Replies: 3
Views: 5042

Re: MyCommand

Here is sample, problem still exists. When qry runned with Command, in field Descr are stored ????? as data.

Code: Select all

USE mydb;

DROP TABLE IF EXISTS `mytable`;

CREATE TABLE `mytable` (
  `ID` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
  `Field1` tinyint(3) DEFAULT NULL,
  `Field2` tinyint(3) DEFAULT NULL,
  `Field3` tinyint(3) unsigned DEFAULT NULL,
  `AppID` tinyint(3) DEFAULT NULL,
  `Report` mediumblob,
  `Descr` varchar(80) DEFAULT NULL,
  `Operater` varchar(20) DEFAULT NULL,
  `LastChange` datetime DEFAULT NULL,
  `NoChange` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO `mytable`(`ID`,`Field1`,`Field2`,`Field3`,`AppID`,`Report`,`Descr`,`Operater`,`LastChange`,`NoChange`) values (31,0,0,3,0,NULL,'Листа корисника у терминалу','admin',NULL,0);
INSERT INTO `mytable`(`ID`,`Field1`,`Field2`,`Field3`,`AppID`,`Report`,`Descr`,`Operater`,`LastChange`,`NoChange`) values (32,0,0,3,1,NULL,'Слике догађаја и запослених','admin',NULL,0);
INSERT INTO `mytable`(`ID`,`Field1`,`Field2`,`Field3`,`AppID`,`Report`,`Descr`,`Operater`,`LastChange`,`NoChange`) values (33,0,0,3,3,NULL,'Детаљни извештај са временима свих улазака/излазака','admin',NULL,1);
INSERT INTO `mytable`(`ID`,`Field1`,`Field2`,`Field3`,`AppID`,`Report`,`Descr`,`Operater`,`LastChange`,`NoChange`) values (34,1,1,3,3,NULL,'Детаљни извештај са почетком-крајем смене и ранијим одласцима','admin',NULL,1);
INSERT INTO `mytable`(`ID`,`Field1`,`Field2`,`Field3`,`AppID`,`Report`,`Descr`,`Operater`,`LastChange`,`NoChange`) values (35,2,2,3,3,NULL,'Стандардни извештај са временима по данима обрачунатих догађаја','admin',NULL,1);

UPDATE `mytable` SET LastChange = NOW();
by davor.TCS
Fri 29 Nov 2019 14:20
Forum: MySQL Data Access Components
Topic: MyCommand
Replies: 3
Views: 5042

MyCommand

I have a problem with MyDAC version 10.0.1 and MyCommand. It does not process corectly UTF8 strings (chars like č, ć, ž, đ). In my connection I set UseUnicode to true.
by davor.TCS
Thu 11 Apr 2019 10:07
Forum: SQLite Data Access Components
Topic: Getting Lock State
Replies: 4
Views: 8889

Re: Getting Lock State

True. Thanks.
by davor.TCS
Sun 07 Apr 2019 06:18
Forum: SQLite Data Access Components
Topic: Getting Lock State
Replies: 4
Views: 8889

Re: Getting Lock State

Busy timeout solved the problem. I did not mention, this application is basically in one exe file. This exe file can be installed as service (then it collects data and writes it in DB file) and as GUI application (then you can set options and view data). Problem was when both try to write data at the same time.
Also, service is behaving very strangely.
At Windows XP on starting computer Service starts (I can stop it, and start it, no problem).
But on OS > Windows 7 Service will not start on starting computer (I can stop it, and start it, no problem)?
I know this is of topic, but if you have any suggestion, please share.

Thank you.