

Squall_FF8
Members-
Content Count
63 -
Joined
-
Last visited
Community Reputation
1 NeutralTechnical Information
-
Delphi-Version
Delphi 12 Athens
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
That is a common misconception among developers and clients. The reason is - contemporary computers are way to fast to objectively judge what is slow and what is fast. Usually developers have fast computers with fast disks/memories. But what happens when you deploy to clients? (files are on the VPN network in my case). I would suggest to put a counter in your CalcField - to simply counts how many times your disk code was used. Then use your app as normal, especially scrolling records/view of the table. And check the counter, right before you destroy the form. You might get a surprise. But whatever number you get, its always a comparison of 1 to many (1 for cashed).
-
Whoah that is exactly my case! Thanks to the help of the guys here, I also came to: "ODBC driver does not recognize these types and maps them to WideStrings" Unfortunately I dont know how to map, (or is it even possible to change it). As an easy fix, I just manipulate the string on GetText, it turned out the first 5 chars is what I need.
-
I dont understand your question .... If you read carefully my initial post, you will see that I use both. As @Uwe Raabe explained well, the Dictionary simply play the role of a cache, specifically - a disk-cache. In Fact the actual FileSize reading is done just once per file/record (on-demand).
-
if not Dic.TryGetValue(QryID.AsInteger, n) then begin var info: TWin32FileAttributeData; GetFileAttributesEx(PChar(QryFileНаме.AsString)), GetFileExInfoStandard, @info); Dic.Add(QryID.AsInteger, info.nFileSizeLow); end; GetFileSize is probably faster, but require more code. Also the result is limited to 4GB. If you need larger sizes you need to account for nFileSizeHigh too.
-
Thank you! So kind of FetchOnDemand approach, I like that. It will be even less code P.S. Does anybody knows why we have such weird execution order: Calc, AfterOpen, Calc? Is there anyway to control this? Or at least to "force" Grid to display the fetched values in the second Calc?
-
Hey guys, I have a table in MS SQL that holds in one column the file names of existing files in a local storage. When I show this table with TFDQuerry, I would like to add visually extra info - the file size. So what I did is to add extra calculated field Size. OnAfterOpen I get the file sizes in a Dictionary<ID, FileSize>, and OnCalcFields I simply fetch the file size from the Dictionary. The problem is - OnCalcFields is called before OnAfterOpen, actually the order by debugging is: Calc, AfterOpen, Calc. The result on screen is - some rows have Size 0 (no value in the Dictionary). After a scroll in the display Grid, all works fine. Could you help me resolve this? Or if you have a better way for a task like this?
-
Thank you! Typing things like Models.List.Field defy my goal to access an object as array: Models.Field, but at least works Later on if I have time I might experiment to change the TList with dynamic array
-
Hey guys, I have a very weird situation: type tModel = record Field: string; Control: TWinControl; Kind: integer; end; tModels = class private FList: TList<tModel>; public procedure DoSomething; ... end; procedure tModels.DoSomething; begin FList[1].Field := 'somthing'; end; When I try to compile I get error: [dcc32 Error] E2064 Left side cannot be assigned to Why I get this error? That would mean I cant have direct access to the fields of the record for manipulation ... P.S. FList[1] := Value; where Value is tModel works.
-
Thank you @Remy Lebeau! BTW do you know, why Image1.Picture.Bitmap.Empty clears the image? It is suppose the return a value, not to destroy an image
-
Hey Guys, I have TImage that in run-time I can load with png or jpg. 1. How to check is the TImage empty (aka no image loaded? 2. How to erase the loaded image? (when an image is loaded)
-
Solid advice! Since I'm stubborn when I feel I'm so close, I decided to test all types (that make sense) - time, time 0..7 and datetime variants. From the 14 possibilities, only 2 gave me (The rest was tWideString): QryHour: TSQLTimeStampField; Browsing MS SQL types page I stubbled upon: So maybe it is ok to get WideStringField. On the other hand, Date formats return SQLTimeStamp ...
-
Update: Sorry guys for the delay but we had a break (National holidays). So I thought that the problem comes from my weird setup: Delphi 12.2, 64 bit application, no design time info for TFDConnection, no SQL for TFDQuerry, all done in run-time. After @Uwe Raabe showed me tTimeField, I decided to play by the book: a new 32 bit app, (because Delphi IDE is 32) design time connection + query (with SQL) , Auto-created fields in design time. All of the fields got appropriate type (Int, Date got TSQLTimeStamp, Currency,..) except the Hour field: QryHour: TWideStringField; If it matters, the MS SQL is old 2008. I also tried to cheat with static field, but the result was the same (error message after opening the query) This leads me to the conclusion: Delphi 12.2 has a bug for MS SQL 2008 when the type is time(7). Unfortunately I cant change the type (easily) to experiment with other time versions or even try DateTime for Time portion. P.S. @Uwe Raabe, I tried your suggestions for mixing static dynamic fields - no result. Sorry but I have to ask - what version is your Delphi and are you using time(7) in MS SQL?
-
Name=Jet DriverID=MSSQL Server=192.168.0.169 Database=xxx User_Name=xxx Password=xxx FDConnection is all default - (after you drop it on the form)
-
The screenshot shows that this is in Design time. Could you try that at runtime? The connection need to be closed on start, and activated with a button. Also the query to have at least 2 fields (Hour and whatever) (so we have a static and dynamic fields at the same time).
-
BTW I'm not sure is it related, but the Query and the Fields are dynamic. The columns are static. I did this because I needed custom labels for titles Here is the CD_Main ... As you can see I have plenty of types, yet they all come as WideString (after Open) CREATE TABLE [dbo].[CD_Main] ( [ID] INT IDENTITY (1, 1) NOT NULL, [ForWho] NVARCHAR (100) NULL, [Dates] DATETIME NULL, [Category] INT NULL, [Sum] MONEY NULL, [Notes] NVARCHAR (200) NULL, [Hour] TIME (7) NULL, ... CONSTRAINT [PK_CD_Main] PRIMARY KEY CLUSTERED ([ID] ASC) );