Recent

Author Topic: [Solved] DBGrid to Edit fields  (Read 2589 times)

JoeCool

  • Newbie
  • Posts: 3
[Solved] DBGrid to Edit fields
« on: September 04, 2018, 03:27:08 am »
Hello,

I am developing a program that uses SQLite DB. I've created two tables that are related and I have to use the INNER JOIN to get all the fields (it was meant to make it smaller). However, I can not use DBEdit, in this case because of a SQLite limitation in "views" situations (SQL changes to read-only status). So I decided to use the DBGrid and TEdit fields to promote updates to the database. I linked my "JOIN query" to a "read-only" DBGrid.
When a row is selected in the DBGrid I'd like to reflect the fields of the row in my TEdit fields. That was easy. The problem is that the Edit fields do not reflect the new value that was assigned. That is, I can not refresh the form.
Any attempt of Form.Refresh and / or equivalent results in an error. Even Application.ProcessMessages also does not work.
Putting the question in a simpler way, I'd like to have the equivalent of TDBEdit with DBGrid using TEdit fields instead. Could someone help me, please?
« Last Edit: September 04, 2018, 04:08:49 pm by JoeCool »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: DBGrid to Edit fields
« Reply #1 on: September 04, 2018, 03:56:14 am »
Hello,

I am developing a program that uses SQLite DB. I've created two tables that are related and I have to use the INNER JOIN to get all the fields (it was meant to make it smaller). However, I can not use DBEdit, in this case because of a SQLite limitation in "views" situations (SQL changes to read-only status). So I decided to use the DBGrid and TEdit fields to promote updates to the database. I linked my "JOIN query" to a "read-only" DBGrid.
When a row is selected in the DBGrid I'd like to reflect the fields of the row in my TEdit fields. That was easy. The problem is that the Edit fields do not reflect the new value that was assigned. That is, I can not refresh the form.
Any attempt of Form.Refresh and / or equivalent results in an error. Even Application.ProcessMessages also does not work.
Putting the question in a simpler way, I'd like to have the equivalent of TDBEdit with DBGrid using TEdit fields instead. Could someone help me, please?
that will not help at all. It is not the TDBEdit that forces the limitation on you is the SQLQuery, the simple way around it,  is to change the properties of SQLQuery to allow editing, that is done by disabling the readonly and providing it with the proper sql commands for update and insert. After that any DB aware edit will allow you to change the data.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

JoeCool

  • Newbie
  • Posts: 3
Re: [Solved] DBGrid to Edit fields
« Reply #2 on: September 04, 2018, 04:18:26 pm »
Thank you. It fix my problem. I was trying go from Rome to Firenze via New York... 

 

TinyPortal © 2005-2018