Recent

Author Topic: Lazarus and Firebird Basic  (Read 764 times)

dstp

  • Newbie
  • Posts: 5
Lazarus and Firebird Basic
« on: October 31, 2024, 04:58:31 pm »
Hello and thanks for taking time to help

I am hoping to create a simple database app using lazarus with firebird

I managed to create a Firebird database and it's running on my local system.
I managed to create a Lazarus app and connected all required (I think) components.
I am using components from the SQLdb tab
Components as follows

SQLConnector
SQLQuery : SQL "SELECT * FROM remind"
SQLTransaction
Datasource

On a form I have
DBGrid
DATEPICKER
DBNavigator

All components are hooked up and the database is active.

I Run the program and all components are active.
I click the INSERT button on DBNavigator
I enter that data in the respective fields

THE PROBLEM

When I click POST on the DBNavigator the Form and controls refresh and everything is disabled and the record is not saved???

Is there perhaps a tutorial Video or Text that outlines steps to create a simple working CRUD Database using SQLdb components.

Or should I be using other component set such as Zeos or other.

I want to create a simple app for reminders. I am using Firebird for it's simplicity and ability to work with dates (better than sqlite for example)

If you require more info to help let me know.

Thanks in advance for any suggestions :-)


Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1255
Re: Lazarus and Firebird Basic
« Reply #1 on: October 31, 2024, 05:49:21 pm »
Hello,
have a look to my database example : Lazarus/Examples/Database/Image_Mushrooms

can use sqlite or firebird

Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

Handoko

  • Hero Member
  • *****
  • Posts: 5386
  • My goal: build my own game engine using Lazarus
Re: Lazarus and Firebird Basic
« Reply #2 on: October 31, 2024, 05:51:24 pm »
Also try this SQLite demo:
https://forum.lazarus.freepascal.org/index.php/topic,65185.msg496461.html#msg496461

With very few modification, the demo can work with Firebird database too.

dstp

  • Newbie
  • Posts: 5
Re: Lazarus and Firebird Basic
« Reply #3 on: October 31, 2024, 10:30:47 pm »
Thank You Jurassic Pork and Handoko

I will examine the examples you provided.

Just after I posted, I decided to try zeos. I was able to create a simple (drag and drop) database where I could add records. I want to use Firebird because of it's ability to work with dates better than sqlite. It is my understanding that sqlite does not support dates directly and requires a bit more work. 

I also did not know that there were examples projects in the Lazarus folder so thanks for that bit of info. It will come in handy.

:-)

rvk

  • Hero Member
  • *****
  • Posts: 6655
Re: Lazarus and Firebird Basic
« Reply #4 on: November 01, 2024, 09:40:33 am »
When I click POST on the DBNavigator the Form and controls refresh and everything is disabled and the record is not saved???
It's difficult to say what is going wrong here.

When working with transactional databases (what Firebird is) you do need to handle transactions correctly.
If you didn't code anything and you just use the TDBNavigator... then a transaction is started.
But if you close the database (or your program) without committing the transaction, all changes will be lost.

The TSQLQuery has some options to do this automatically.
You can set sqoAutoApplyUpdates, sqoAutoCommit and sqoKeepOpenOnCommit in the options.
After doing that... you posts will stay in the database.

It is my understanding that sqlite does not support dates directly and requires a bit more work.
Actually... SQLite does support dates... but does not have specific date fields.

SQLite is a bit of an odd duck regarding SQL standards. It has few datatypes and in the TEXT field it can handle (and supports) different types of variables.

So SQLite can actually put dates in TEXT, REAL and INTEGER fields. And it supports those dates in those fields just fine. You just need to know how to handle them.
https://www.sqlite.org/datatype3.html

For simple single use database SQLite is the way to go. Although I prefer Firebird myself, because you can switch between 'embedded' and full server without changing anything in code. But if you are going to use Firebird (or other transactional database) you need to learn more about transactions.



egsuh

  • Hero Member
  • *****
  • Posts: 1529
Re: Lazarus and Firebird Basic
« Reply #5 on: November 01, 2024, 11:18:30 am »
Please post the simplest form that you have difficulty, only with a few fields of DB.

 

TinyPortal © 2005-2018