* * *

Author Topic: [SOLVED] Multiple SQLite3 Tables  (Read 440 times)

Landslyde

  • Full Member
  • ***
  • Posts: 140
[SOLVED] Multiple SQLite3 Tables
« on: May 27, 2018, 08:04:16 pm »
I have a SQLite3 db in a DBGrid with a Label below it on a form. One of the tables has three records, five fields each. One is a name field. What I'm trying to do is, either by clicking or scrolling, make the Label.caption := the name in the name field. Once I get this then I can use other tables to reflect data based on the name selected. This is just test stuff to meet that end.

The only thing I've came up with is this:
Code: Pascal  [Select]
  1. Label1.Caption:=DBGrid1.SelectedField.CurValue;
But I have to hop from field to field (column to column) to get it to change. And then I get a segment fault when I end the program.

I've tried everything I can think of before making this post. If you can send me off in the right direction, I'd appreciate you. Thanks.

« Last Edit: May 30, 2018, 12:10:18 am by Landslyde »
Linux Mint 18.3
Lazarus 1.8.4
FPC 3.0.4

HeavyUser

  • Full Member
  • ***
  • Posts: 146
Re: Multiple SQLite3 Databases
« Reply #1 on: May 27, 2018, 08:31:56 pm »
I have a SQLite3 db in a DBGrid with a Label below it on a form. One of the tables has three records, five fields each. One is a name field. What I'm trying to do is, either by clicking or scrolling, make the Label.caption := the name in the name field. Once I get this then I can use other tables to reflect data based on the name selected. This is just test stuff to meet that end.

The only thing I've came up with is this:
Code: Pascal  [Select]
  1. Label1.Caption:=DBGrid1.SelectedField.CurValue;
But I have to hop from field to field (column to column) to get it to change. And then I get a segment fault when I end the program.

I've tried everything I can think of before making this post. If you can send me off in the right direction, I'd appreciate you. Thanks.


you write an on after scroll event on the sqlquery and your code there for example
Code: Pascal  [Select]
  1. procedure TForm1.SQLQuery1AfterScroll(DataSet :TDataSet);
  2. begin
  3.   label1.Caption := DataSet.FieldByName('name').AsString;
  4. end;
  5.  

Landslyde

  • Full Member
  • ***
  • Posts: 140
Re: Multiple SQLite3 Databases
« Reply #2 on: May 27, 2018, 09:06:45 pm »
Thank you, HeavyUser. That's opens doors.
Linux Mint 18.3
Lazarus 1.8.4
FPC 3.0.4

mangakissa

  • Hero Member
  • *****
  • Posts: 796
Re: [SOLVED] Multiple SQLite3 Databases
« Reply #3 on: May 28, 2018, 08:39:22 am »
That's only works if the SQLQuery is on the form and not on a datamodule.
Lazarus 1.64 (32b) / FPC 3.0
Windows 10

HeavyUser

  • Full Member
  • ***
  • Posts: 146
Re: [SOLVED] Multiple SQLite3 Databases
« Reply #4 on: May 28, 2018, 09:51:25 am »
That's only works if the SQLQuery is on the form and not on a datamodule.
if you mean that the event handler needs access to the forms controls in order to work then yes you are write, if you mean that the event will not fire outside the form then no. As always discretion is required.

Landslyde

  • Full Member
  • ***
  • Posts: 140
Re: [SOLVED] Multiple SQLite3 Databases
« Reply #5 on: May 28, 2018, 03:45:25 pm »
Noted.
Linux Mint 18.3
Lazarus 1.8.4
FPC 3.0.4

Landslyde

  • Full Member
  • ***
  • Posts: 140
Re: [SOLVED] Multiple SQLite3 Databases
« Reply #6 on: May 29, 2018, 08:57:33 pm »
That's only works if the SQLQuery is on the form and not on a datamodule.

Indeed. I'm finding drawbacks when I use the DataModule. Gets in the way and messes up the good stuff.
« Last Edit: May 30, 2018, 12:08:35 am by Landslyde »
Linux Mint 18.3
Lazarus 1.8.4
FPC 3.0.4

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus