Forum > LCL

TDBGrid Issues Depending On SQLite Database Type

<< < (2/3) > >>

emhartner:

--- Quote from: Zvoni on September 13, 2022, 02:59:54 pm ---
--- 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)

--- End quote ---

I don't see how this will help tell the DBGrid what the proper sizes of the fields are.  Again - if I create the fields programmatically as I do in the CreateFields procedure, the field sizes and column widths are correct - but I end up getting the EXC_BAD_ACCESS upon posting an insert.  If I don't call the CreateFields, then the field sizes are too small.

Zvoni:
I still don't understand, why you're creating the TStringFields (or what you need them for)
https://lazarus-ccr.sourceforge.io/docs/fcl/db/tstringfield.html

--- Quote ---Field class to handle ansistring fields

--- End quote ---

--- Quote ---TStringField is the class used whenever a dataset has to handle a string field type (data type ftString). This class overrides some of the standard TField methods to handle string data, and introduces some properties that are only pertinent for data fields of string type. It should never be necessary to create an instance of TStringField manually, a field of this class will be instantiated automatically for each string field when a dataset is opened.

--- End quote ---

wp:

--- Quote from: emhartner on September 13, 2022, 11:54:00 pm ---I don't see how this will help tell the DBGrid what the proper sizes of the fields are.  Again - if I create the fields programmatically as I do in the CreateFields procedure, the field sizes and column widths are correct - but I end up getting the EXC_BAD_ACCESS upon posting an insert.  If I don't call the CreateFields, then the field sizes are too small.

--- End quote ---
When your concern is the column width in the DBGrid, you could use DBGrid.Columns[colum_index].Width := some_pixel_value, or SQLQuery1.Fields[field_index].DisplayWidth := some_character_count.

rvk:
And if you get a (MEMO) in the TDBGrid field when you use TEXT you can change that in the DBGridOnGetText() event or you can set dgDisplayMemoText in the options of the TDBGrid.

See https://stackoverflow.com/questions/4809298/lazarus-dbgrid-showing-memo-as-the-value-of-string-fields-in-sqlite-3

Zvoni:
I still don't understand why you need to set the Fieldsizes, considering SQLite ignores any sizerestrictions on Table-Columns

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version