Jump to content

JonRobertson

Members
  • Content Count

    171
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonRobertson

  1. JonRobertson

    Help with Query at run time

    The first thing to change is to set conPLife.Connected to False before building the project. When Dinobase launches and loads your main form, it is attempting to immediately open the database connection because Connected is set to True at design-time. Setting Connected to True is very useful while you are developing, but it needs to be set to False before building a project that will run anywhere except on your development machine. This is a pain and there are ways to automate it. But that is a different post. ;) I would have expected removing the path in Params.Database to resolve the path issue. But I do not have experience with SQLite or FireDAC. If you are certain the database will always be in the same folder as the .EXE, the path can be adjusted before opening the database. Here is one approach, which I put at the top of FormCreate: procedure TfrmDino.FormCreate(Sender: TObject); //Form creation begin conPLife.Params.Database := IncludeTrailingPathDelimiter(TDirectory.GetCurrentDirectory) + conPLife.Params.Database; conPLife.Connected := True; tblPLife.Active := True; Note that System.IOUtils needs to be added to your uses clause to resolve the reference to TDirectory. This is still not ideal, but it works for your first project. An ideal solution would be to store the database and images in a folder intended for app data, such as TPath.GetPublicPath (typically C:\ProgramData). There are other folders that you could use. Through the years, Microsoft has changed gears on app data folders a few times. After that, I copied the dino_images and dino_size folders from your earlier zip to my project folder and was able to run your project, navigate the db, and see the images. I have a couple of quick suggestions from a brief look at your form's code. Your Exit button calls "self.Close". "self." is not needed here. There are times that it is useful for clarity, but not necessary. The btnExitClick method is a member of TfrmDino, so calling Close calls the Close method of TfrmDino. You declared sName, recno, and recnum as globals in the var section of the unit. You should get in the habit of declaring "form" related variables as members of the form, as private members when possible. (Although it seems recno and recnum are not currently needed.) private sName: String; Lastly, pay attention to warnings from the compiler: [dcc32 Warning] Dinobase_u.pas(126): W1036 Variable 'iSelect' might not have been initialized How should lbxDataClick "behave" if lbxData.ItemIndex is not greater than -1? Jon
  2. JonRobertson

    Help with Query at run time

    Same for me. I suspect your code is still hardcoding the path to the database.
  3. JonRobertson

    Help with Query at run time

    Take a look at the AfterScroll event of the dataset. If the code that loads an image is not already a separate function/procedure, move it to one. Then call that from the AfterScroll event. https://docwiki.embarcadero.com/Libraries/Sydney/en/Data.DB.TDataSet.AfterScroll
  4. JonRobertson

    Help with Query at run time

    He meant don't use a modified TDBNavigator. You said at some point something about adding your own buttons. If the buttons provided by TDBNavigator provide the functionality you are wanting but you weren't able to get it to work as intended, that can be corrected. If you want additional buttons to provide functionality that is not built into TDBNavigator, that is a different story. For what you are doing, you should get the project working using single dataset component and a single datasource component. Based on your posts, it seems as though you may be using multiple datasets. I would use a separate dataset to load the picture. But that is easier to implement once the project works using a single dataset.
  5. JonRobertson

    Help with Query at run time

    That code would add sName. But sName may be an empty string ('') at that point of code execution. Have you confirmed that sName contains a value when LoadFromFile is called? Have you set a breakpoint to examine sName before LoadFromFile is called? Or added a ShowMessage(sName) before calling LoadFromFile?
  6. JonRobertson

    Help to find database error

    I was able to get his project working on my machine. I don't use SQLite either. So as a test I tried several combinations of character case on the table name and they all worked. Table names (and likely any object name) do not seem to be case sensitive. His project also works with the database connection and query assigned 100% in code, with zero design-time configuration.
  7. JonRobertson

    Help to find database error

    His project was building to Project\Win32\Debug and dat2.sqlite was in the root Project folder.
  8. JonRobertson

    Delphi 12: Install Packages inconsistency?

    I disagree. No reason for the IDE to load packages if they won't be needed by my next action. My next action could be closing the IDE or loading a different project that also does not use all of the default packages. The only issue that occurs to me is if my next action was to create a new form, without loading or starting a project first. In that case, I may be confused why a package is not loaded that I would expect to be loaded. But I wouldn't want to change the design or code of a form without having a project loaded. There is a lot of IDE functionality unavailable in that scenario.
  9. JonRobertson

    Help to find database error

    Sure, because that is the path that you hardcoded to FDConnection1.Params.Database: Try this instead: FDConnection1.Params.Database := ExtractFilePath(Application.ExeName) + 'dat2.sqlite'; If ExtractFilePath is an undefined identifier, add SysUtils to the uses statement below the implementation keyword.
  10. JonRobertson

    Help to find database error

    The easy way to test anything in programming is to intentionally break code. For example, in your SQLite project, change Database= to a file that you know does not exist. When I did that, I got a dialog saying "unable to open database file." Using the link you provided, I did that tutorial with the Employee.s3db database in Embarcadero's samples folder, and it worked as expected. And if I change the query to SELECT * from dat2, I get the same error you are (as I would expect with this database). Attached is my version of the tutorial project. Object names don't match the tutorial and I added output when no rows are returned. It attaches to a database named dat2.db in the same folder as the project. The screenshot you posted of the database & table did not have "data type" for each column. Are you sure you have completely created *and* saved the database? I used DB Browser for SQLite and there is a button to "Write Changes". My best guess is the database file that your Delphi project is opening does not have a table named dat2. Tutorial.zip
  11. I would not suggest jumping into the source of an IDE Expert. There are many open source repos that could be beneficial. Here are a few, and these are just github. Embarcadero GitHub - Project samples included with the past several versions of Delphi and some other interesting repos. Delphi topic on GitHub - Over 2,200 open source projects Edit: This may be useful: Coding Boot Camp 2022
  12. Search engines are your friend. Here is a small list. None of these offer structure like a training course or a classroom curriculum. But there are some worthwhile articles and videos. https://delphi.fandom.com/wiki/Delphi_Wiki https://www.delphibasics.co.uk/ Embarcadero YouTube LearnDelphi.tv Delphi Programming Tutorials Not free: Embarcadero Academy I personally prefer books. Shortly after I started using Delphi, my go to Delphi bibles were Mastering Delphi 2 and Delphi Developer's Handbook, both by Marco Cantu. Most everything in those books still apply, although they were written nearly 30 years ago. There are several good "current" Delphi books that would cover more recent language additions but may assume the reader already knows the basics. Coding in Delphi and More Coding in Delphi by Nick Hodges are good for the Delphi language itself. But check out other authors as well. There are a number of excellent books on Delphi by some great authors.
  13. JonRobertson

    Help to find database error

    Is that tutorial online? If so, please post a link.
  14. JonRobertson

    Help to find database error

    That isn't the ConnectDB_u.dfm for the ConnectDB_u.pas that you posted above. The name of the form in that DFM is TForm1 and none of the components on your TfrmConnectDB form are in the DFM code you posted. It should look more like this: object frmConnectDB: TfrmConnectDB Left = 0 Top = 0 Caption = 'frmConnectDB' ClientHeight = 442 ClientWidth = 628 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Segoe UI' Font.Style = [] TextHeight = 15 object btnConnect: TButton Left = 280 Top = 232 Width = 75 Height = 25 Caption = 'btnConnect' TabOrder = 0 OnClick = btnConnectClick end object btnExecute: TButton Left = 280 Top = 312 Width = 75 Height = 25 Caption = 'btnExecute' TabOrder = 1 OnClick = btnExecuteClick end object memOutput: TMemo Left = 320 Top = 56 Width = 185 Height = 89 TabOrder = 2 end object SQLConnection1: TSQLConnection DriverName = 'Sqlite' Params.Strings = ( 'DriverUnit=Data.DbxSqlite' 'DriverPackageLoader=TDBXSqliteDriverLoader,DBXSqliteDriver280.bp' + 'l' 'MetaDataPackageLoader=TDBXSqliteMetaDataCommandFactory,DbxSqlite' + 'Driver280.bpl' 'FailIfMissing=True' 'Database=') Left = 304 Top = 384 end object SQLQuery1: TSQLQuery Params = <> Left = 416 Top = 296 end end
  15. JonRobertson

    Help to find database error

    Open ConnectDB_u.dfm in Notepad, copy entire contents to the clipboard, and paste that in a reply to this post. I am curious how SQLQuery1 is configured in the form designer. Another approach is to select SQLQuery1 in the form designer, press ctrl-c to copy just that component to the clipboard, and post it. But there could be other helpful details in the entire DFM, such as how SQLConnection1 is configured.
  16. Has anyone attempted to add VCL Styles support to TChromeTabs? In my search, I see Jerry Dodge asked the author on StackOverflow back in 2015, who responded he did not use VCL Styles and had no plans on adding the support. I can attempt to do it. I think most of the work would be in TCustomChromeTabs.DrawCanvas. Unfortunately, I have very little experience writing custom drawing/painting code and no experience implementing VCL Styles in a component. Can anyone recommend a book or online resource to get my feet wet?
  17. JonRobertson

    VCL Styles support for TChromeTabs

    Thank you for the suggestion. I have looked at code by Ray, Chris Rolliston, and Rodrigo Ruz. My first attempt was a good learning experience. Now I need to start over and do it piece by piece.
  18. Except you don't run the Delphi IDE on any system. An IDE that is not cross-platform will have limited cross-platform capabilities. Going down that discussion is going off-topic, imo. That said, I agree that an editor having "front-end" capabilities is a good thing. And some of those may depend on integrating with backend services, such as a LSP server, which may or may not be on the local machine.
  19. Yes. I have a license for Pro Edition. I have been a user and fan of BC since version 1. But I do not care for the Delphi IDE integration. I use the Explorer integration and have TortoiseGit configured to use BC.
  20. I agree that Undo would be beneficial in the form designer. Saying that, "change history" is one of many benefits of good source control, such as git. I use "Git diff with previous version" quite often with both DFM and PAS files. And DPROJ, for that matter. I have Beyond Compare installed with Delphi IDE integration. Unfortunately I am not a fan of BC's Delphi integration. It has bit me more than once.
  21. JonRobertson

    Getting Win 11 in Delphi

    I don't understand the question. On my Windows 11 laptop, TOSVersion.ToString returns Windows 11 (Version 22H2, OS Build 22621.2715, 64-bit Edition) You could look at TOSVersion.Create in System.SysUtils.pas. TOSVersion.Name should also return "Windows 11"
  22. JonRobertson

    What is the benefit of sorting the Uses clause?

    Is it published? I looked on https://blog.dummzeuch.de/ but could not find it there or in GExperts.
  23. Are wildcards supported in () groups? Is this list valid for MMX? Winapi;System.Win;System;Data;Vcl;(hyie*,ie*,imageen*);pp*;Rz*;ra*;vcl.ww* Ctrl-Alt-U is moving (hyie*,ie*,imageen*) below everything in the list. My expectation is that my () group is invalid and MMX is ignoring it. Before: uses Winapi.Windows, System.Classes, System.Generics.Collections, System.ImageList, System.SysUtils, Data.Win.ADODB, Vcl.ActnPopup, Vcl.BaseImageCollection, Vcl.Buttons, Vcl.Controls, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.Forms, Vcl.Graphics, Vcl.ImgList, Vcl.Menus, Vcl.PlatformDefaultStyleActnCtrls, Vcl.StdCtrls, Vcl.OleServer, Vcl.VirtualImageList, hyiedefs, hyieutils, iemio, iemview, ieview, iesettings, iexBitmaps, iexLayers, iexProcEffects, iexRulers, iexToolbars, iexUserInteractions, imageenio, imageenproc, imageenview, RzButton, RzCmboBx, RzLabel, RzPanel, RzSplit, RzShellDialogs, SVGIconImageCollection, SVGIconImageListBase, SVGIconVirtualImageList, OutlookXP, uAisDocument, uUserSettings, udmResources, udmDocResources; After: uses Winapi.Windows, System.Classes, System.Generics.Collections, System.ImageList, System.SysUtils, Data.Win.ADODB, Vcl.ActnPopup, Vcl.BaseImageCollection, Vcl.Buttons, Vcl.Controls, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.Forms, Vcl.Graphics, Vcl.ImgList, Vcl.Menus, Vcl.PlatformDefaultStyleActnCtrls, Vcl.StdCtrls, Vcl.OleServer, Vcl.VirtualImageList, RzButton, RzCmboBx, RzLabel, RzPanel, RzSplit, RzShellDialogs, hyiedefs, hyieutils, iemio, iemview, ieview, iesettings, iexBitmaps, iexLayers, iexProcEffects, iexRulers, iexToolbars, iexUserInteractions, imageenio, imageenproc, imageenview, SVGIconImageCollection, SVGIconImageListBase, SVGIconVirtualImageList, OutlookXP, uAisDocument, uUserSettings, udmResources, udmDocResources;
  24. JonRobertson

    Can not install Delphi Community Edition 11.2

    You can give a reaction to a post, such as Thanks. Hover your mouse over the heart icon in the lower right corner of a post to select a reaction.
  25. JonRobertson

    What is the benefit of sorting the Uses clause?

    How do you configure groups like (ZipForge)? I could not find that in MMX Properties or MMX Project Options. I would like to do this for ImageEn and maybe others. ImageEn units do not have a consistent prefix suitable for grouping. Thanks! Thanks
×