Jump to content

Columbo

Members
  • Content Count

    99
  • Joined

  • Last visited

Everything posted by Columbo

  1. Columbo

    Help with Query at run time

    Thanks Remy. That looks exactly like what I want however, I am getting an error with that code. The only change that I made to your code is, that for testing purposes, I tried to only get the name data from the database. Here is the code: procedure getdbrecord; var sName: String; begin Query.SQL.Text := 'SELECT name FROM dino where name = :PName'; Query.ParamByName('PName').AsString := sName; Query.Open; edtName.Text := Query.FieldByName('name').AsString; I am getting the following errors. E2003 Undeclared Identifier 'Query' E2029 '(' expected but ':=' found I tried adding Query: String under the var but it made no difference. I've only been playing with Delphi 11 for about 2 weeks so I'm still a baby at this stuff. end;
  2. I'm trying to find a way to change the color of the Titlebar and TLabel fonts and TEdit fonts to my own chosen colors. The 'Color ' menu does not give you a lot of choices. A lot of greys and whites but few colors and I don't see any way to add a color such as #562703 or RGB 86,39,11. Is it possible to do this? Thanks
  3. Columbo

    Custom color not in color property list

    Thanks Serge, I am using Delphi 11 Community. I didn't do anything with StyleElements because I was not aware of what that does. What I used was lblName.Font.Color := TColor(#575). When I run the program it works ok. As for the Tabs, I don't want to place an image in them permanently. I have a database with 115 records and each record has 2 images associated with it. When a record is selected I want it to display the associated images, one in each tab. I need to know how to place these images into the tabs programmatically. I have searched the internet and I see lots of discussion on placing images into tabs permanently using TImageList but nothing on how to do it at run time.
  4. Columbo

    Custom color not in color property list

    I managed to accomplish what I was trying to do by using a TabSheet. It seems to work where the TabPanel would not. I placed a TImage control in each tab and loaded an image in each tab just to test it and it works as I wanted it to. I removed the images since they were just for testing and now I will try to figure out how to load an image into each TabSheet programmatically.
  5. Columbo

    Custom color not in color property list

    Thanks guys, I think I've got that now. I guess should do this in another post but my problem now is with a tabbed panel. I created a panel with 2 tabs. I want to load 2 images, one image into each tab. I tried to put a TImage control in each tab but that does not work. Once the TImage control is placed in Tab1, you can no longer switch tabs. If you load and image into the TImage control the same image is displayed in both tabs. I don't have room on my form to create 2 separate panels with separate TImage controls. I have searched all over for a solution but can't find anything on this. Suggestions?
  6. Columbo

    Custom color not in color property list

    Thanks David, I did happen to come across that video and found out how to do it, although again in that video he uses colors from the 'Color' drop down menu. I need to use my own custom color #502F0F.
  7. Columbo

    Help to find database error

    I’m trying to learn Delphi 7 and at the moment I am trying to figure out how to access and retrieve data from a SQLite database. I found a short pdf tutorial and I followed the instructions but it is flagging a Undeclared identifier: ‘ShowSelectResults’. I have gone over the code several times comparing it to the code in the pdf tutorial and I can’t find anything different. The line that is highlighted in Delphi is ShowSelectResults(); I assumed that it might be something wrong in the procedure TDatabaseTutorial.ShowSelectResults(); but if it is I can’t figure out where, unless there is an error in the tutorial. Can anyone give me a hint as to what is causing this? Here is my code: unit DatabaseTutorial_u; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DBXpress, FMTBcd, DB, SqlExpr, StdCtrls; type TfrmDatabaseTutorial = class(TForm) btnConnect: TButton; btnExecute: TButton; SQLConnection1: TSQLConnection; memOutput: TMemo; SQLQuery1: TSQLQuery; procedure btnConnectClick(Sender: TObject); procedure btnExecuteClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var frmDatabaseTutorial: TfrmDatabaseTutorial; implementation {$R *.dfm} procedure TfrmDatabaseTutorial.btnConnectClick(Sender: TObject); begin SQLConnection1.Params.Add('D:\Borland Delphi\Test Projects\Database Tutorial\Data\Dat2.sqlite'); try //Establish the connection SQLConnection1.Connected := true; btnExecute.Enabled := true; memOutput.Text := 'Connection Established!'; except on E: EDatabaseError Do ShowMessage('Exception raised with message' + E.Message); end; end; procedure TfrmDatabaseTutorial.btnExecuteClick(Sender: TObject); var query : String; begin memOutput.ClearSelection; //Set up a Query query := 'SELECT * FROM hline1;'; try //Assign the query to the object SQLQuery1 SQLQuery1.SQL.Text := query; SQLQuery1.Active := true; except on E: Exception Do memOutput.Text := 'Exception raised with message:' + E.Message; end; //Show the result of the query in memOutput ShowSelectResults(); end; procedure TDatabaseTutorial.ShowSelectResults(); var headline : TStringList; i : integer; currentField: Tfield; currentLine : string; begin If not SQLQuery1.IsEmpty Then begin SQLQuery1.First; headline := TStringList.Create; try SQLQuery1.GetFieldNames(headline); While not SQLQuery1.Eof Do begin currentLine := "; for i := 0 to hline1.Count -1 Do begin currentField := SQLQuery1.FieldByName(headline(i)); currentLine := currentLine + ' ' + currentField.AsString; end; memOutput.Lines.Add(currentLine); SQLQuery1.Next; end; headline.Free; end; end; end.
  8. Columbo

    Help to find database error

    FYI: I was able to convert all of my SQLite files to csv using SQLite Studio. It was quick and easy.
  9. Columbo

    Help to find database error

    Thanks Stano,. I am aware that importing data from one DB to another has nothing to do with Delphi. I was asking if there was perhaps a utility out there that may convert .DBF files. I have heard of Firebird and a companion program called FireRobin but I would need to check it out.. Does it have a steep learning curve or something? Thanks again Stano
  10. Columbo

    Help to find database error

    Thanks Gary, I am currently using Delphi 11 Community on my son's computer with Windows 10 on it. The computer that my son loan me has Windows 7 Professional on it and has Delphi 7 on it. It doesn't have fireDAC of course and I don't know the requirements of FireBird so I don't know if it runs on Windows 7. I just checked the Ebarcadero web site and it says: "Delphi CE includes a code editor, powerful debugging tools, built-in access to popular local databases with live data at design time, Bluetooth capabilities, and a visual UI designer with support for pixel perfect, platform-specific styling. " So it appears to support some databases. At this point in time I am not concerned with mobile apps. I first want to learn Delphi before doing anything too serious but most of the stuff that I do use databases. I'll have to check and see if the Community version supports Interbase Lite. Is there any way that import or convert either .DBF or SQLite to Interbase? BTW: You are actually 3 hours behind me in California.
  11. Columbo

    Help to find database error

    I have downloaded a few videos on Delphi and on databases and I am going to try something a bit different as a means of learning Delphi. I notice that a few people have said that they never use SQLite. I used it because I already had 7 SQLite databases containing a lot of data ranging from the year 1900 to 1997. I didn't want to have to redo all of that. What database format is most commonly used for Delphi programming? I also have the same databases in DBF format from my original program written in CA-Clipper. Is there a way to convert those to a Delphi usable format?
  12. Columbo

    Help to find database error

    I was following Gary's instructions. Didn't want to confuse myself with other methods until I was able to do it by the instructions. I finally got it to work using his instructions.
  13. Columbo

    Help to find database error

    I'll try it tomorrow. I don't know where you are but I am in Toronto, Canada and it is 12:36 am and I think I'm going to hit the sack for the night. Thanks again.
  14. Columbo

    Help to find database error

    Thank you Gary, It works! The FDTable works fine if I want to retrieve all data, but if I need to pull the data from a specific column of a table row the FDTable would not work so well. I have a long way to go in learning Delphi and I am not sure yet how to get the data from a specific column in a row. I am guessing that it would be something like: SELECT hline1 FROM DAT2 WHERE hyear = 1942 But at least now I know that the database dat2.sqlite can be accessed, I now have to figure out why it is not working in the FDQuery. Thanks again for your patience on this. VERY MUCH appreciated.
  15. Columbo

    Help to find database error

    I put the FDTable component on the form, set the connection property to conMain, Set the Connection to Connected, Set the TableName property dropdown menu to DAT2 and set the Active to True. Nothing happeded. How do I test it? If I right click I don't see an Execute button.
  16. Columbo

    Help to find database error

    SELECT statement had no quotes or semi colon. What Databse tool?
  17. Columbo

    Help to find database error

    Connection property is set to conMain. When I right click and click on 'Execute' I get that dialog about ' [FireDAC][Phys][SQLite]-310 Cannot execute command returning result sets, Hint use Open method for Select-lite commands. ' Not sure what the -310 means.
  18. Columbo

    Help to find database error

    I get a dialog saying 'Connection established successfully'.
  19. Columbo

    Help to find database error

    Yes, I did have it set it to Connected : True. Here is a screenshot of the FDConnection Editor.
  20. Columbo

    Help to find database error

    Thanks Gary for your time and your patience. I followed your instructions on Step1, (FDConnection1) component. I called it conMain. I added the button as per your instructions and when run it I get the message 'Connected!'. Then I added the btnConnect and when I run it I get the 'Connected!' message again. So far so good... Then I added the FDQuery component. I set the name to qryDat2. I went to SQL in the Inspector, clicked on the ... next to 'Database' menu item and entered: SELECT * FROM DAT2 Then you said I wasn't sure as to where this was but I clicked the dropdown menu for 'Connection' and set 'Connected' to True. When I right click Query and select Execute I get a dialog that says: 'Cannot execute command returning result sets, Hint use Open method for Select-lite commands.' So I have probably entered something wrong somewhere and I can't go any further on your instructions until I get this resolved.
  21. Columbo

    Help to find database error

    Hi Gary, I started a new project as you suggested called FDTest2. Following your instructions I added a FDConnection and set the DriverName to SQLite, and set the name to conMain. You then said: When I select ... it opens the String List Editor but I am not sure what to put in here. Currently it says "DriverID=SQLite" . Do I leave that in there and add a a path to the sqlite database on the next line or do I replace the "DriverID-SQLite" with the path to the database or is there something else that goes in here? Thanks.
  22. Columbo

    Help to find database error

    Thanks for all of the help. I took a day off to clear my head and I'll try again starting from scratch and see what happens.
  23. Columbo

    Help to find database error

    I commented out the original path and replaced it with: FDConnection.Params.Database := ExtractFilePath(Application.ExeName) + 'dat2.sqlite'; SysUtils was already in the uses statement. Still no connection. I am almost ready to give up on this thing and try something else.
  24. Columbo

    Help to find database error

    If I go into the Win32 directory I have 2 files. FDtest_p.exe and FDTest_u.dcu. If I run the FDtest_p.exe I get the same ShowMessage as I mentioned in my previous post to Gary, 'D:\Delphi_11_Community\MyProjects\Data\dat2.sqlite '.
  25. Columbo

    Help to find database error

    Hi Gary, I had the driver set up in the properties as SQLite. I set the 'Connected' property to true. I set the path to: FDConnection1.Params.Database := 'D:\Delphi_11_Community\MyProjects\Data\dat2.sqlite'; After the path I added: ShowMessage(FDConnection1.Params.Database); When program is run the message I get the path D:\Delphi_11_Community\MyProjects\Data\dat2.sqlite. I also left in the code: ShowMessage(FDQuery1.SQL.Text); When program is run this gives me the message: query := 'SELECT * FROM DAT2'; In the FDQuery1 Properties I opened the SQL editor and added: query := 'SELECT * FROM DAT2'; It still doesn't connect.
×