

Squall_FF8
Members-
Content Count
77 -
Joined
-
Last visited
Everything posted by Squall_FF8
-
Hey guys, I wanted to do simple thing - use Aggregates. So following the help: procedure TForm.Button1Click(Sender: TObject); begin if Qry.Aggregates.Count = 0 then with Qry.Aggregates.Add do begin Expression := 'COUNT(Town)'; Active := True; Qry.AggregatesActive := true; end; end; Should be pretty simple, right? But I get error (on Activate := true): Do you know why? What I'm doing wrong?
-
Thank you very much!!! Usually thigs like this have default name that is good enough (it works, the name = you dont use/dont care) Are you talking for Aggregates in general, or my example of use?
-
Hey guys, I have a shared folder on the local net that I want to be able to Copy/Move/Delete files from it with a Delphi application. It works great when I share that folder with unlimited access. For security requirements I cant do that - I need to make it accessible only with user/pass Do you know how I can that?
-
Hi guys, I have a TFDQuerry connected to MSSQL that returns a record with field Test - nvarchar(max). I would like to be able to Paste a text from Word in a RichEdit and be able to save it (formatted as RTF) in Test and latter on load it from there. How I can do that? (code snippet) P.S. If possible I try to use Insert/Update statements, but if I have to - I will use BLOBs. I just dont understand how blobs work in conjunction with normal Insert/Update.
-
If I remember correctly, the whole concept/interface with Post, Edit, EoF, First, Next,... was created for BDE, but was so loved/easy to use by developers that its functionality was replicated in general and every new DBset specific for specific DB (DAC, FireDAC, I even had components for Postgre and Oracle implementing those). It doesn matter for the thread, but for general DB perspective, MSSQL as a spiritual successor of Access, comes natively packed with auto-inc. So you dont need triggers for that. Later versions added Sequence (I guess influenced by Oracle ). Even IBX adopted Sequence, which if used makes Generators a little obsolete.
-
THANK you very much for that explanation!!! It clears my confusion. I assume that is the BDE way, but I missed that class (academic, not Delphi) 🙂 BTW what happens with the ID after Insert? Is it automatically received or you need to make sure that Insert statement have the right things (like 'OUTPUT INSERTED ID' in MS SQL)
-
How I can do that for create (Insert)? My Query returns only 1 record, from Where clause (usually ID of a table). But if it is a new record ...? BTW Using Select to Insert/Update - that will never come to my mind 🙂 I understand that actual operations come from Edit/Append. Thank you!
-
It will be interesting to peek in a snippet of it ^_^ How that works in conjunction with TQuery? I mean, when I call ExecSQL with Insert/Update, TDBRichEdit automatically provides the context for my BLOB field (no extra code)? Or I need to provide some code before/after ExecSQL?
-
TBH, I dont know how to escape for MS SQL query. However as you said control codes are not needed for RTF standard, so I just made a routine that skips them. And all works fine now!!! BTW this might be interesting for you - Delphi and WordPad put exact same control codes. In my observation - 13, 10 after \par and 0 at the end. Good point - great suggestion! Thank you very much for taking time to write detail answers!!!
-
Thank you @Tom Chamberlain for the code and comments!!! I'm sure it will be very helpful. Later today I will examine it very carefully.
-
Yes, I had similar problem. If you scroll down, you should find my post - I updated everything for future reference (as the case is now) In short the problem is from 32/64 mode. Windows come with mdb support only for 32. In 64 you can use mdb/accdb (because we usually install 64 versions of Access). And because Delphi is still 32 ... no design mode (unless you do something hacky (like '/passive /quiet') to have 32 drivers too. But I have to admit, that Delphi couldnt get all the blame. If you work with well supported DB (for example MS SQL) you get both 32/64 drivers.
- 14 replies
-
OK, I did: // To get RTF var Stream := tStringStream.Create; Rich.Lines.SaveToStream(Stream); Result := QuotedStr(Stream.DataString); // for Insert/Update, the text needs quotes However when I use the result in Query, I get error - it messes up the syntax of the SQL. So I inspected the returned DataString ... It seems it uses not just plain text, but control codes: 13, 10, 0. That creates 2 problems: 1. QuotedStr - formats it in Delphi way: 'text'#13#10'text'.... SQL doesn't like that! 2. #0 is considered end of a string (most of the times) and Delphi cuts what follows. Questions: - Since when RTF includes control codes (ASCII < 32)? If that is the case then things like `\par` are nonsense. - The RTF text states version 2.0. Do you know what version of RichEdit Delphi 12+ uses? Because of: "{\rtf1\ansi". I'm not familiar with "RTF using 8bit characters". Does Delpji / Windows RichEdit supports that? Do you know of a program that supports that?
-
Hey guys, I'm trying to make a document in FastReport that will look like: * Contract Text - RichText with some data fields. text could be huge (more then a page!!!) * Small Table - TableObject with 2 columns for Contract Objects (max 4 lines) * Contract Text - same as above. I did that in FastReport like: * ReportTitle (logo + ...) * MasterData (band) - RichText - TableObject with event for Manual Build and code copied from Demo (how to make TableObject display DB) - RichText * PageFooter (for Page Numbers) And it didnt work: - The TableObject is not shown!. I suspect Manual build is not called. If I put it directly on Page1 it works. It works with other bands too, just MasterData - no. You would think - just remove MasterData, but: - Since RichText is huge, I can make it print on several pages only inside MasterData. Is there any other ways? Could you guys advise me? How you would implement such document? If it matters, my version is 2023.2.
-
Not even a suggestion! Does that mean, that nobody is using FastReport?
-
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?
-
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).
-
Hey Guys, I use a stock TDBGrid (Delphi 12.2) connected to an FDQuerry (MS SQL). One of the field is Hour (time7) and I would like to customize the output to just "hh:mm". Could you advise how that could be achieved?
-
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 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! 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 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)
-
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