Jump to content

Gary

Members
  • Content Count

    137
  • Joined

  • Last visited

Everything posted by Gary

  1. Gary

    Help to find database error

    Look at the image of the Object inspector, it is the first property. You connect to the database by setting the connection to "Connected True". Check or uncheck the box in the Object Inspector. Image's I posted are for the connection, look close, there is no SQL this is the connection, only properties having to do with the connection to your Database. Any SQL will be in the Query component. Right Click the FDQuery and select Query editor, see image. Enter your SQL statement. No quotes or semicolon SELECT * FROM DAT2. Press execute if good you will see your data below and the SQL for the component will be populated, if not your SQL Statement is the problem. Even though you can see the table in the Database it doesn't mean your SQL is valid. I once had a problem when migrating a MySQL server from Windows to a NAS drive. The default on the NAS did not allow capitols in table names and the whole program would not work because all my tables were a mix of lower and uppercase, SQL was now invalid. If the program you use to create/modify your SQLite database allows you to write queries do so. Make sure it works and then copy it into the FDQuery
  2. Gary

    Help to find database error

    When you look at the Object inspector there are 4 properties to set, see the image below. Line 4 DriverName has a dropdown list set it to SQLite Line 9 LoginPrompt if you do not have passwords set this to false and no login prompt will show Line 10 Name change to something better than default I like conMain or something more descriptive of your DB Expand the Params Property and the third line is the Database path. the ... will open a File Open dialog. Now set Line 1 Connected to true, if you get no errors and it stays checked your good. Even easier is Lajos suggestion, Right click FDConnection select Connection Editor, you can set all parameters except LoginPrompt there and it even has a Test button. This is the great thing about Delphi. The sample image attached I created in about 30 Seconds without a single line of code. I know you don't need the grid but it is a way to easily confirm that you have a valid DataSet. From your posts I suspect there are simple typo's and a mixture of trying to set properties in code and at design time. I think your SQL statement is the culprit, not the actual statement but how you are trying to set it in code, forget about that and just enter it in the FDQuery SQL property. If you want we can walk through setting up your Dataset like the sample and you can concentrate on your processing code.
  3. Gary

    Help to find database error

    Don't give up!! Start over with fresh project and break it into smaller parts: 1) Connect to Database 2) Open Query 3) Process your data I Created a small test app to complete the first 2 steps and test them in less than 1 Minute with the Demo data, you can too! 1) With a fresh project drop a FDConnection on the form. In Object inspector Set DriverName to SQLite. Set Name to conMain (Easier to type latter) Open Params look for Database, use ... to navigate to your Database. Now set Connected to true. If all is well it will connect. Set Connected to False Add a button to the form Set name to btnConnect and Caption to Connect. Double click button and add code: conMain.Connected := True; if conMain.Connected then begin ShowMessage('Connected'); // btnOpen.Enabled := True; end; Run and press Connect. If all is well you'll get the message. Step 1 Done Add a FDQuery to form Set Connection to conMain (Designer will probably already have done it for you) set Name to qryDat2 Enter your SQL statement into the SQL Object inspector Set Connection back to Connected <-Important Right click Query, you'll get a dialog box with your SQL in it. Press Execute. If all is well you'll see your data. Set Connected back to False. Add another Button Set enabled to false. Name to btnOpen, Caption to Open. Double click and add code: qryDat2.Open; if qryDat2.Active then begin ShowMessage('Query Active'); // btnProcess.Enabled := True; end; Uncomment btnOpen.Enabled := True; Run and try it!! Add third button Set Name btnProcess Enabled to False; Caption Process Double click button and add your processing code here Uncomment btnProcess.Enabled := True; You can delete each setting individually and try adding them in code 1 at a time to get a better understanding.
  4. Gary

    Help to find database error

    Very helpful to have the tutorial link. You can set everything up in the designer to make sure it works, then try doing it all in code. Set the Connection's Connected property to true, you will get errors if everything is not set up. You may be missing the connection's driver name, notice the drop down. Select SQLite or in code: FDConnection1.DriverName := 'SQLite'; Add the Query to the FDQuery1' SQL property in the editor and set it's Active property to true, you'll get errors if it's not setup right. The Database path is wrong, you are setting the Connection's "Database" Parameter which is a file path. So it's "Database=" then path. You can set it 2 ways: FDConnection1.Params.Add('Database=' + Your path here); FDConnetion1.Params.Database := Your Path here; You can use "ShowMessage" for a little logging. After setting the Database path: ShowMessage(FDConnection1.Params.Database); Test after opening the connection: if FDConnection1.Connected then ShowMessage('Connected'); After setting the SQL: ShowMessage(FDQuery1.SQL.Text);
  5. Gary

    Help to find database error

    I started with Lotus Approach and dBase files 🙂 Just wondering, you know while your project is great for learning Delphi you can do the same thing with components and hardly any code? That's what got me interested in Delphi in the beginning. Drop a TDBGrid and TDataSource on the form, connect the Grids DataSource property to the TDataSource, set the DataSource's DataSet property to your Query and when you open the Query it populates the Grid automatically including FielNames as headers.
  6. Gary

    Help to find database error

    Coding Boot Camp 2022 – Learn to Program (learndelphi.org) This was great for beginners. Delphi must be used in schools in South Africa, many of the sessions were from instructors there and referred often to this book: Dr Kevin R Bond on Delphi-Books.com
  7. Gary

    New proyect in Delfos

    FWIW I'm a hobbyist with 1 commercial app out there that is only on a LAN. I use Delphi Pro with Devart Unidac the standard edition is $299.00 Pro $499.00 they have a 15% sale good for 4 more days. I have a few personal and non-profit databases in the cloud, Dreamhost $13.99 mo. using 2 tier solutions (direct connection) with MySQL, and it's no more difficult than using a local database, just get the server address from the provider. It works fine. I do have to do most of the database management with their tools though. Like Carlos I keep hearing that it's all old school, and unsafe. REST is the way to go. While REST itself seems pretty straightforward with many tutorials on how to do it on a local computer, they all stop there. If you have no experience with web development it's the deployment that is the roadblock. I once asked about deploying REST to Dreamhost on a webinar and the response was "It can be done but was difficult with that provider". So what kind of provider service do you need? How do you connect the REST server to the database hosted in the cloud? Responses are usually like David's "I would suggest registering for a AWS account 12 months free tier and using Aurora PostgreSQL." (absolutely no offence intended). Looking at AWS's offerings will give you a headache, and what is "Aurora"? Another layer? It would be great if there were a tutorial out there with a real-world example of setting this up on a real host. I purchased TMS All Access. It comes with components to create a REST server and more. Also their class and Holger's books and am looking forward to some time to dig into it, but in skimming the info It wasn't obvious it will cover that. Still I'm hopeful.
  8. Gary

    Help to find database error

    Yes! What Remy said! Your form is your class and defined in the interface section of the file. This is just the description or declaration of the class, you write the code later in the implementation section type TfrmDatabaseTutorial = class(TForm) //<- Class name btnConnect: TButton; btnExecute: TButton; SQLConnection1: TSQLConnection; memOutput: TMemo; SQLQuery1: TSQLQuery; procedure btnConnectClick(Sender: TObject); //<- procedures of your class no need for TfrmDatabaseTutorial procedure btnExecuteClick(Sender: TObject); //<- procedures of your class no need for TfrmDatabaseTutorial private { Private declarations } public { Public declarations } procedure ShowSelectedResults;//<- procedures of your class no need for TfrmDatabaseTutorial end; // <- Definition of your class ends here When you write your code the unit needs to know what class your procedure belongs to since you can have multiple classes, so you need it here: implementation TDatabaseTutorial needs to be here so compiler knows what class the procedure belongs to. Multiple classes can have the same procedure names and often do so you have to distinguish them. procedure TDatabaseTutorial.ShowSelectResults; begin //code end;
  9. Gary

    Help to find database error

    look at the event handlers Delphi created btnConnectClick(Sender: TObject) and btnExecuteClick(Sender: TObject) to see this. You can use ctrl + shift + up or down arrow to toggle between interface and implementation sections. Also it doesn't hurt but the () are not needed if you have no parameters.
  10. Gary

    Help to find database error

    It's easy to get confused at first. What ioan is saying the procedure "ShowSelectResults" or "ShowSelectedResults" you decide has to match. However, in the implementation section at the top inside your class TfrmDatabaseTutorial in the public section you do not use the class name just public { Public declarations } procedure ShowSelectedResults; Down below in the implementation section where you write your code you need the class name then a period then the procedure with exact spelling procedure TDatabaseTutorial.ShowSelectedResults(); begin //code end; If you get rid of the class name from the implementation section and just leave "procedure ShowSelectedResults;" then with your cursor on the line press ctrl + shift + c Delphi will create the implementation section for you and you don't have to worry about spelling.
  11. I use a similar approach as aehimself for Window programs with an addition I saw in a Holger Flick video. He created a very simple static TController class and replaced the .dpr code with a single line: begin TAppController.Run; end. This way you don't have to add code to the .dpr which I have had cause trouble in the past since Delphi edits this file as well. You can add code to the Run procedure and not worry about messing things up. TAppController = class public class procedure Run; private class function CheckSingleton: Boolean; class procedure SetFocusRunningInstance; end; class function TAppController.CheckSingleton: Boolean; begin Result := FindWindow(WINDOW_CLASS_NAME, nil) = 0; end; class procedure TAppController.SetFocusRunningInstance; begin ShowWindow(FindWindow(WINDOW_CLASS_NAME, nil), SW_SHOWMAXIMIZED); end; class procedure TAppController.Run; begin Application.Initialize; Application.MainFormOnTaskbar := True; if TAppController.CheckSingleton then begin //Add conditional defines, splash screen whatever Application.Run; end else begin TAppController.SetFocusRunningInstance; end; end; Someone else (Can't remember where) also suggested setting the main form window to something unique you need to override the CreateParams of the Main form. procedure TfrmMain.CreateParams(var Params: TCreateParams); begin inherited; StrCopy(Params.WinClassName, WINDOW_CLASS_NAME); end;
  12. Follow the tutorial. Setting "Movement" in the event is just the first step, the actual moving of the image is done later with a timer.
  13. If you are following the tutorial you should start a new project. Select New / Multi-Device Application not Windows VCL Application. In this case the Windows VCL TListBox component does not have the " var KeyChar : char" parameter that the Multi-Device TListBox component has. Many others could be different as well and that would create serious cause of confusion.
  14. Here you go Will. The tutorial is a multi platform application, you started a VCL application, the controls have different parameters.
  15. Interesting, I looked at the video Will is following take a look at 2:54. The tutorial's ListBox OnKeyDown event has an additional parameter var KeyChar : char that the instructor is using therefore the 'w' instead of Ord('w'). My ListBox doesn't have that parameter and neither does Will's. Anybody know what's going on? 2:06 shows Delphi 10.2
  16. Hello all, Anyone else have this problem? I get a quote from Embarcadero for my renewal with a link. Go to link fill in all information and press submit or whatever. I get a failed message, and the link no longer works because it actually went through, at least the charge did. Embarcadero has no record of payment but My card company cleared the transaction March 1st 7 days ago. I had the same problem last year and complained to Embarcadero. Just wondering if it's just my issue or has anyone else had issues with online subscription renewal?
  17. Hello all, I have an app that dynamically changes the style. On close it saves style to ini and reloads on startup. Changing style and closing is fine with any style except if the app has changed style to windows. App crashes after writing to ini, so if app starts with windows style and closes without changing all is fine. I logged the OnClose of the Main form and get no errors. Debug shows the problem in the TStyleEngine.DoUnregisterStyleHook call and jumps to System here: function _IsClass(const Child: TObject; Parent: TClass): Boolean; begin Result := (Child <> nil) and Child.InheritsFrom(Parent); end; I have included the EurekaLog file. Any help? Gary EurekaLog.txt
  18. Gary

    Delphi 11.3 is available now!

    11.3 on my laptop 13" Project menu doesn't fit on screen and cannot scroll so Project/Options (Last Item) and Eurekalog options are inaccessible. Anyone else have this problem?
  19. Gary

    Delphi Registration

    Once again Embarcadero's licensing policy causes pain!! 11.3 is out so I cleaned up the 2 computers I have Delphi installed, one with a complete reinstall of Windows, however something I have been wanting to do for some time is rename both from the stock unintelligible names. I did contact support about this in advance and since I'm on contract, they told me no problem. Took today off for this big install -- Registration limit exceeded!! I did email support for a bump but have a totally wasted day, and who knows how long it will take? BTW just paid ransom yesterday, expires on the 12th.
  20. I use WebView4Delphi as well. Recently I needed to manipulate a web site to navigate to, select a report, run it then download the report as a csv file. WebView4Delphi had all the needed control. I have never done web development, so it took several days and multiple Stack Overflow posts to get it to work but it has been running flawlessly for weeks now, downloading every half hour.
  21. Delphi 11.2 WebView4Delphi Hello all, I posted on StackOverflow yesterday, but no solution, probably because this seems to be such an easy fix. I am totally new to Web/JavaScript programming and just need to refresh and download a csv file from a geo location service every half hour. I have everything working except what should be the easiest part, simply clicking the refresh button on the page. I am using an ActionList and menu to test each step for now. What I have so far: A running app that can navigate to the site, open the report, and download the file to a Nas drive overwriting the previous file. The download logs when finished. Before downloading I need to refresh the report. If I inspect the element in the browser it takes me to this list item: <a id="linkRefresh" href="#" class="tools refresh report-action" data-action="refreshReport" data-event="click"> <span class="report-edit-icon refresh"></span> <span class="tool-label">Refresh</span></a> In my test action I have this code: procedure TfrmLocation.actRefreshReportExecute(Sender: TObject); begin WVBrowser.ExecuteScript('document.getElementById("linkRefresh").click()'); end; Nothing happens, is there something I'm missing? Is there an easier way to do this? Is there a way to verify that a valid element is being returned? Can there be more than one document in the page, this button is inside a frame with a #document element? I have spent 2 days on this so far, any help would be appreciated.
  22. Gary

    Click button from WVBrowser

    @salvadordf I figured it was a matter of drilling down to the element. 3 hours later after much trial and error, Success!! So frustrating spending so much time for what you already know is going to be 1 or 2 lines of code because of your ignorance but satisfying when done. Thank you so much.
  23. Hello all, I am going to do a clean install of Delphi but don't want to install all the old components that I no longer use. I still need them to support legacy apps, so want to try loading up a VM with those components. What are you using for VM, and what settings work best? My current Machine: 11th Gen Intel(R) Core(TM) i7 32 GB Ram 1 TB SSD Windows 11 Delphi 11.2 I would also like to run it on an older laptop 10th Gen i7 16 GB Ram 1 TB SSD Or is there a better way to support old apps that use components who's license has expired?
  24. Gary

    VM and Legacy apps

    @jonnyg You're correct, I should have been clearer. I just run the latest version of Delphi but have some components that the update has expired as well as open-source components I no longer use. I did buy a Windows 11 license and install Delphi and the needed components to support my old app. All seems to work well. The only problem I have had is the VM will lock up at times requiring a reset.
  25. There is an interview with the author on Embarcadero's YouTube channel you may be interested in Upgrading and Maintaining Delphi Legacy Projects
×