Jump to content

Serge_G

Members
  • Content Count

    315
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Serge_G

  1. Serge_G

    Syntax error in From clause

    Perhaps because you define your fields and let the parameter required value to true Yes if the datasource of the grid is a Table I understand sort is not working, but one time it's depending on components you use On my side, I quite don't use FDTable, only FDQuery and FDUpdateObjects, but as I remember FDTable can be sorted using properties as IndexFieldName PS. You don't indicate if you are on the VCL or the FMX side of Delphi and I don't remember seeing version you use
  2. Serge_G

    Syntax error in From clause

    1- you don'd need any trigger if you use generated identitity 2- for date use date type or timestamp type 3- for amountex use something like NUMERIC(8,2) if currency
  3. Serge_G

    Syntax error in From clause

    Ok, it's because you change domain. Keep it to a somewhat RDB$anumber wich is the domain for the column. In brief, don't change what is purposed by default in this zone
  4. Serge_G

    Syntax error in From clause

    Hi, what a strange usage ! I don't understand the InputBox usage, so borring But first Are you using Firedac or another set of components ? What version of Firebird did you install ? There are at least two ways : using a SEQUENCE (aka GENERATOR) and a Trigger or using if FB3+ GENERATED BY DEFAULT AS IDENTITY (see this versions notes) With flamerobin you can easily create the GENERATOR/Trigger like this (create the table quick 'CREATE TABLE test ( ID INTEGER NOT NULL PRIMARY KEY, Texte VARCHAR(30) )' ) and then dbclick to open properties of new table With SEQUENCE you don't have to take care about ID your code //get next ID //dmTaS.tblJobCard.Sort := 'ID ASC' ; //dmTaS.tblJobCard.Last; //iID : = dmTaS.tblJobCard['ID'] + 1 ; //insert values to DBgrid dmTaS.tblJobCard.Insert ; // dmTaS.tblJobCard['ID' ] := iID ; let it to null, Firebird is in charge ... dmTaS.tblJobCard.post; But, if you use Firedac I can suggest you more efficient coding i.e const InsertSQL= 'INSERT INTO jobCard (orderno,jobname,StartDate,Completiondate,amount) values (?,?,?,?,?.)'; begin dmTas.fdConnection.ExeSQL(InsertSQL, [sOrderNo,sJobName,sStartDate,sCompletionDate,sAmountEx]);
  5. Ah, I was not so clear. FDPhyFBDriver is not compatible with Android and IOS. It's not a FB version problem. I use only FBclient on Android (Firebird 4 or 3 no matter) and connect to a Fb 2.5 server (without any problem) but only with ZEOSDBO components. Vandrovnik change some part of IBX.IBIntf.pas to access Firebird instead of Interbase (see this discussion) I am not so optimist I think (and really prefer Firedac)
  6. Serge_G

    Syntax error in From clause

    There are 2 ways to use Firebird : Firebird Client/Server - You have to deploy the DB and Firebird on the other pc Firebird Embedded - You have to put some files and directories in the same directory than application For a multi user Firebird app, it's quite the same approach except you deploy only client part, with the Firebird Setup it's easy, embedded you need at least fbclient.dll and perhaps firebird.msg files in the same dir that the app. Recommendation : Don't copy the DB file, uses backup/restore. Use a GUI Tool like Flamerobin
  7. Serge_G

    Syntax error in From clause

    Hi one parenthesis to delete in the first line dmTaS.query_JobCard.SQL.Add('Insert into JobCard'); Lacking of a parenthesis after 'Values' dmTaS.query_JobCard.SQL.Add('Values (:ID :OrderNo, :JobName)'); Consider other solutions to write SQL to be more clear, i.e. const ISQL = 'INSERT INTO JobCard (ID ,OrderNo ,JobName) VALUES ( :ID :OrderNo, :JobName)'; // the "good" SQL for INSERT begin dmTaS.query_JobCard.Close; dmTaS.query_JobCard.SQL.Text:=ISQL; dmTaS.query_JobCard.Parameters.ParamByName('ID').Value := lb_ID.Text; dmTaS.query_JobCard.Parameters.ParamByName('OrderNo').Value := lb_OrderNo.Text; dmTaS.query_JobCard.Parameters.ParamByName('JobName').Value := lb_JobName.Text; dmtas.query_JobCard.ExecSQL; // dmTaS.query_JobCard.SQL.Clear; // unnecessary you use SQL.Text dmTaS.query_JobCard.SQL.Text := 'Select ID ,OrderNo ,JobName from JobCard'; // let's say I prefer list of columns needed rater tha a * dmTaS.query_JobCard.Open; Under this form, it's easier to maintain IMHO
  8. Serge_G

    CDATA Woocommerce component

    Hi, still in experimentation. We have one woocommerce site, but traffic is low and interfacing (integrating orders/updating stocks) with my Delphi ERP is not a high priority. So I only made some connection and query tests
  9. Interesting, I certainly prefer Firedac (why is the FDPhysFBdriver is not compatible is to me largely incomprehensible) and never think to use IBX instead 😲! I have tried other third party components to reach a Firebird DataBase like ZEOSDBO or UNIDAC, succesfully (even if deploying firebird on Androïd is really challenging the firsts times )
  10. Serge_G

    TSpeedButton - how to change the background color

    Yes, acting so even if you change stylebook at run time this custom style is independent Yes, even if it's not so easy, you have to change about three PNG images (dpi necessity) . I remember a video by Sarina Dupont about using Adobe and Stencils to change colors (see this tool) sorry, I don't found the link and many others interventions (videos, blogs) about bitmap designer tool Basically, using bitmap designer tool : save image , edit images with whatever tool you have, and then return to bitmap designer, load the new image (hoping this should not change regions defined, I never check this) Yes, you should say : "but bitmap designer is for VCL" (VSF file) but it's easy to save it as a FMX style I guess increasing the size of the image, putting the desired drawing outside the already defined areas will do the trick
  11. Serge_G

    TSpeedButton - how to change the background color

    Well, it's FMX, so you can change the style (creating a custom one or modifying existent) Here I delete initial background, put a TRectangle (aligned contents), sending it background (control/background) and set property stylename to background too. Advantage you can "easily" change color of a Trectangle. Inconvenient : - if you want to use all other buttonstyles, you have to do the same thing ! - if you use dark colors, take care of the fontcolor Notice, same as always, if you use it for all platforms change default style not the "Windows" default one
  12. Serge_G

    [FMX] Dll not found

    Hi, I was testing D11 and Python4Delphi components (Getit version) With VCL 32 bits and 64 bits application execute, 👍 good job Same program FMX but, if 64 bits is OK, 32 bits raise an exception. Any explication ?
  13. Serge_G

    [FMX] Dll not found

    Hi, thanks. UseLastKnownVersion is/was checked (by the way it's the 3.10.2) I was not aware of this property, unchecking it raise an "could not open Dll "python310.dll" exception (always and only on 32 bits)
  14. Hi, in my application I offer to the user the possibility to change style (light/dark) procedure TStartForm.SwitchThemeSwitch(Sender: TObject); begin Datas.StyleBookLight.UseStyleManager:=false; Datas.StyleBookDark.UseStyleManager:=false; if SwitchTheme.IsChecked then MainForm.StyleBook:=Datas.StyleBookDark else MainForm.StyleBook:=Datas.StyleBookLight; datas.parametres.blacktheme:=SwitchTheme.IsChecked; Datas.StyleBookLight.UseStyleManager:=not SwitchTheme.IsChecked; Datas.StyleBookDark.UseStyleManager:=SwitchTheme.IsChecked; {TODO -obug -cGeneral : TListview style don't apply on first lines} end; All is working except on my TListView, as you can see. Here I change from light to dark, font text color is still black on these lines, scrolling down the color is the "normal" white I remember I bang this bug another times, I override this by deactivating and then reactivating the link, but this is time-consuming when there are many records! Is there another way ?
  15. Serge_G

    Changing Style at runtime and TListview

    Hi, this "bug" is corrected in version 11 (and perhaps 10.4, I don't check that)
  16. Serge_G

    64 bit PostgreSQL and Embarcadero ???

    Hi, first you have to install the two versions of PostgreSQL (32 and 64) the first for the IDE the second when running/debugging 64 apps On the other hand, at runtime you can change library path (before connecting ) for this you need to put a FDPhysPgDriverLink (give it a DriverID, id to be used by FDConnection) and then you will be able to change Vendorlib
  17. Serge_G

    Grayscaling an image (memory leak)

    HI, I wrote this unit to grayscale an image unit ImageUtils; interface uses System.SysUtils, System.UITypes, System.UIConsts , System.Math, FMX.Types, FMX.Graphics, FMX.Utils; type Talgorithm = (algnone,algluminosity,algaverage,alglightness); function ConvertToGrayscale(const aBitmap: TBitmap; const aMethod : TAlgorithm=algnone) : TBitmap; overload; function ConvertToGrayscale(const FileName : String; const aMethod : TAlgorithm=algnone) : TBitmap; overload; implementation function Colortogray(const aColor : Talphacolor; const aAlgo : TAlgorithm=algnone) : Talphacolor; var H,S,L : Single; C : TAlphacolorRec; // https://www.johndcook.com/blog/2009/08/24/algorithms-convert-color-grayscale/ begin RGBToHSL(aColor,H,S,L); c.Color:=acolor; case aAlgo of algluminosity: begin H:=Trunc(0.2126*c.R) + Trunc(0.7152*c.G) + Trunc(0.0722*C.B); Exit(HSLToRGB(H,S,L)); end; algaverage: begin var mean : integer := (c.R + c.G + c.B) div 3; c.R:=mean; c.G:=mean; c.B:=mean; Exit(c.Color); end; alglightness: begin H:=(maxvalue([TAlphacolorRec(aColor).R,TAlphacolorRec(aColor).G,TAlphacolorRec(aColor).B]) + minvalue([TAlphacolorRec(aColor).R,TAlphacolorRec(aColor).G,TAlphacolorRec(aColor).B])) / 2; Exit(HSLToRGB(H,S,L)); end; else Exit(HSLtoRGB(0,0, L)); end; end; function ConvertToGrayscale(const aBitmap: TBitmap; const aMethod : TAlgorithm=algnone): TBitmap; var X, Y: Integer; bd1, bd2: TBitmapData; p1, p2: PAlphaColorArray; begin Result := TBitmap.Create(Round(aBitmap.Width), Round(aBitmap.Height)); if (aBitmap.Map(TMapAccess.Read, bd1) and Result.Map(TMapAccess.Write, bd2)) then begin try for Y := 0 to (aBitmap.Height - 1) do begin p1 := PAlphaColorArray(bd1.GetScanline(Y)); p2 := PAlphaColorArray(bd2.GetScanline(Y)); for X := 0 to (aBitmap.Width - 1) do begin p2[X] := Colortogray(p1[X],aMethod); end; end; finally aBitmap.Unmap(bd1); Result.Unmap(bd2); end; end; end; function ConvertToGrayscale(const FileName : String; const aMethod : TAlgorithm=algnone): TBitmap; var X, Y: Integer; bd1, bd2: TBitmapData; p1, p2: PAlphaColorArray; Source : TBitmap; begin Source:=TBitmap.Create; try Source.LoadFromFile(FileName); Result := TBitmap.Create(Round(Source.Width), Round(Source.Height)); if (Source.Map(TMapAccess.Read, bd1) and Result.Map(TMapAccess.Write, bd2)) then begin try for Y := 0 to (Source.Height - 1) do begin p1 := PAlphaColorArray(bd1.GetScanline(Y)); p2 := PAlphaColorArray(bd2.GetScanline(Y)); for X := 0 to (Source.Width - 1) do begin p2[X] := Colortogray(p1[X],aMethod); end; end; finally Source.Unmap(bd1); Result.Unmap(bd2); Source.Free; end; end; except Source.Free; result:=nil; end; end; end. But I don't understand where I miss something because I have some memoryleaks --------------------------- Unexpected Memory Leak --------------------------- An unexpected memory leak has occurred. The unexpected small block leaks are: 29 - 36 bytes: TD2DBitmapHandle x 1, TBitmapImage x 1 45 - 52 bytes: TBitmap x 1 61 - 68 bytes: Unknown x 1 --------------------------- OK ---------------------------
  18. Serge_G

    Grayscaling an image (memory leak)

    Thanks, I was looking for an error in the bad unit !
  19. Serge_G

    Grayscaling an image (memory leak)

    Sorry, I tried to edit my first message but don't work procedure TfrmMain.btnGriserClick(Sender: TObject); begin if OpenDialog1.Execute then begin Image1.Bitmap.LoadFromFile(OpenDialog1.FileName); image2.Bitmap:= ConvertToGrayscale(image1.Bitmap); // image3.Bitmap:= ConvertToGrayscale(image1.Bitmap,TAlgorithm.algluminosity); // image4.Bitmap:= ConvertToGrayscale(image1.Bitmap,TAlgorithm.algaverage); // image5.Bitmap:= ConvertToGrayscale(image1.Bitmap,TAlgorithm.alglightness); end; end; result Well, I try this ones // https://www.johndcook.com/blog/2009/08/24/algorithms-convert-color-grayscale/
  20. Serge_G

    FB3 Get Connected Users List

    Hi, and happy new year. As far as I know about Firebird the system tables are prefixed MON$, RDB$ and (SEC$ starting with FB 3.0) not TMP$ to get privilege(s) on a table you can use select RDB$USER,LIST(RDB$PRIVILEGE) from rdb$user_privileges where RDB$RELATION_NAME=<tablename> GROUP BY 1 but some fields can be involved too so in this "list" you can find some repetitions Here is the result of a SELECT a.RDB$USER, a.RDB$RELATION_NAME,-- a.RDB$FIELD_NAME, LIST(a.RDB$PRIVILEGE) RIGHTS FROM RDB$USER_PRIVILEGES a WHERE a.RDB$RELATION_NAME='LLANCEMENT' GROUP BY 1,2; But this don't give the "reality" of the rights user FOURNISSEUR (supplier) don't have the same field access than USINE (factory) And take in mind you can change ROLE. I never really looked into the possibility of changing the access to the editing areas of a shape from the rights declared in a Firebird database, Interesting challenge for my future retirement
  21. Serge_G

    SQLite to MySQL

    FDBatchmove, yes a good tool and if it is a one shot operation you don't need to run the program you can make all your ops during design time, changing tables or querys and using context menu to run it but at runtime with these conditions should be esay too
  22. Serge_G

    Which version BDE

    I don't agree you can use ADO driver, even if I agree with your second remark Not necessarily Firebird : Paradox = Mon User so SQLite is sufficient FDTable have these functions, personally I prefer FDQuery but ...
  23. Serge_G

    error on Interbase 2020 server

    WITH dt2 AS ( select goods_id, sum(qty) as inc, cast(0 as float) as sale, cast(0 as float) as writeoff from income where cast(recdate as date) <= :d group by goods_id union all select goods_id, cast(0 as float), sum(qty) as sale, cast(0 as float) from sales where cast(recdate as date) <= :d group by goods_id union all select goods_id, cast(0 as float), cast(0 as float), sum(Qty) as writeoff, from writeoff where cast(recdate as date) <= :d group by w.goods_id) ) select G.Goods, G.Goods_id, coalesce(dt2.incomes,0)as incomes, coalesce(dt2.sales,0) as sales, coalesce(dt2.writeoffs,0) as writeoffs, coalesce(dt2.endqnts,0) as endqnts From Goods G JOIN dt2 on G.Goods_id=dt2.Goods_id on G.Goods_id=dt2.Goods_id order by G.Goods I think that, if CTE is really effective in Interbase 2020, this one is more clear Some notes : - Using alias in a union is not useful - I change the where clause in the last part of the union : where cast(recdate as date) <=:d ( hoping that this column exists in the table "writeoff") Question the JOIN between Goods and dt2, it shouldn't rather be a LEFT JOIN
  24. Serge_G

    Which version BDE

    You spoke about Database Desktop not Delphi 7, I am confused 😲 D7 works on Windows 10, I install/uninstall it about once a month
×