* * *

Author Topic: [Solved] Filling TCombobox from a SQLite3 database  (Read 353 times)


  • New member
  • *
  • Posts: 17
[Solved] Filling TCombobox from a SQLite3 database
« on: January 08, 2018, 06:58:23 pm »
I've saved some data into a STRING field of an SQLite3 database.  Then I retrieve that data with a SELECT DISTINCT statement to fill a TCombobox.   All works well until the first data is a number, like 105, then the TCombobox fills with all zeros, even though 105 was saved to the database as a string.   

I've tried testing the data with IsNumber(), then converting it to a string with IntToStr before sending it to the TCombobox, but haven't gotten IsNumber to work yet.  But it seems the data should already be a string anyway.

Update 1: The problem doesn't seem to be with the TCombobox because I can display the first record, 105, in a TLabel.Caption indicating it is indeed a string, but when I try to display the second record, which is alpha, in TLabel.Caption it displays a 0.

Update 2:  If I change the datatype in the database to Char or Text, it works.  Numbers will fill TCombobox as well as alpha.  Which is best to use, since I want to be able to store numbers as well as alphanumeric characters.

« Last Edit: January 08, 2018, 10:10:47 pm by rickielynn »


  • Hero Member
  • *****
  • Posts: 1947
  • My goal: build my own game engine using Lazarus
Re: Filling TCombobox from a SQLite3 database
« Reply #1 on: January 08, 2018, 07:26:04 pm »
Bugs can happen anywhere in the source code. Without inspecting the code, we can't be sure to say where you did wrong.

Please copy all the necessary files including the database into a new folder, excluding the lib folder, binary (*.exe) and bak files. Compress the folder and send the zip file to the forum. If for some reasons you're not willing to publicize the code, you can write a demo sample showing that issue.


  • Full Member
  • ***
  • Posts: 124
Re: Filling TCombobox from a SQLite3 database
« Reply #2 on: January 08, 2018, 09:53:28 pm »
In SQlite if you don't define a default value to a column, then it's null, may be this. But as @Handoko saids, show the code and the table.
Lazarus 1.6 FPC 3.0.0 Linux Mint Mate 17.2 x86_64 GTK-2
Zeos 7.1.3 - Sqlite 3.8.2

Foro Lazarus en español http://forum.lazarus.freepascal.org/index.php/board,73.0.html


  • New member
  • *
  • Posts: 17
Re: Filling TCombobox from a SQLite3 database
« Reply #3 on: January 08, 2018, 10:10:14 pm »
Thanks, guys.  I didn't publish any code because I think the problem is in SQLite3.  I changed the records from type STRING to type TEXT in SQLite3 and the problem went away.



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