Forum > LCL

TDBGrid Issues Depending On SQLite Database Type

(1/3) > >>

emhartner:
I'm seeing inconsistencies in the TDBGrid based on the SQLite data type.  The attached program will create a table with three fields with the fields being one of the following data types:
- VarChar(2000)
- Text(2000)
- Text
- WideChar

The following is the behavior for each type:
VarChar(2000):
Everything works as it should.

Text(2000)
If "Insert Data Upon Creation" is checked, no data is shown when the table is created.
Upon posting a new row, you get EXC_BAD_ACCESS.
Upon putting data in a column in a new row, and then moving to a new column, you get EXC_BAD_ACCESS.

Text
Exactly the same as Text(2000)

WideChar
If "Insert Data Upon Creation" is checked - the test data is shown when the table is created as with VarChar(2000).
Upon posting a new row, you get EXC_BAD_ACCESS.

My database utilizes WideChar and this used to work without issue in Lazraus 1.8.  It also works fine in Delphi 7 and in Objective-C on iOS.

Can anyone tell me how make it work with the other data types I list?

Thank you,
Eric

Zvoni:
I'll never understand people insisting, SQLite uses those DataTypes, nevermind "enforcing" Fieldsizes
https://www.sqlite.org/datatype3.html#affinity

--- Quote --- Note that numeric arguments in parentheses that following the type name (ex: "VARCHAR(255)") are ignored by SQLite - SQLite does not impose any length restrictions (other than the large global SQLITE_MAX_LENGTH limit) on the length of strings, BLOBs or numeric values.

--- End quote ---

wp:
Why do you create the fields yourself? TDataSet.Open normally does this automatically in case of an existing database. When I remove your call to "CreateFields" the crashes are gone.

emhartner:

--- Quote from: wp on September 13, 2022, 10:31:10 am ---Why do you create the fields yourself? TDataSet.Open normally does this automatically in case of an existing database. When I remove your call to "CreateFields" the crashes are gone.

--- End quote ---

Thank you for your reply wp.  Without creating the fields ahead of time, I have two problems:
(1) The column widths are incorrect.
(2) The field sizes are wrong.  Here are examples:
- VarChar(2000) is correct at 2000
- Text(2000) is 0 - treated as memo
- Text is 0 - treated as memo
- WideChar is incorrect at 255

Is there another way to ensure I get the field size I need?

Thank you,
Eric

Zvoni:

--- Quote from: emhartner on September 13, 2022, 01:11:55 pm ---Is there another way to ensure I get the field size I need?

Thank you,
Eric

--- End quote ---
Yes, store those "metadata" in a separate table (think INFORMATION_SCHEMA of MySQL)

Navigation

[0] Message Index

[#] Next page

Go to full version