A few TZMemTable remarks
Posted: 29.01.2021, 20:57
Hello,
Just a few remarks for the new TZMemTable component:
- ftMemo, ftString, ftFixedChar will throw a nullpointer exception upon opening:
Issue is in ZMemTable.pas : 208
TZMemTable has no connection, so Connection.ControlsCodePage is referring to nil.ControlsCodePage. Lines 208 and 209 can be deleted, items can be merged with the next condition:
- The above also renders the condition in : 217 useless, as it will never be true:
I created a small patch with the above, will issue a pull request soon.
With that said, I have the following code:
I have a DataSource and a DBGrid connected, and it is showing that 'MyField' is WideMemo instead of String, which I explicitly created:
The reason is, ConvertDbcToDatasetType sets the fieldtype as WideMemo, if there is no length specified. I can see the reason, just want to ask if it is intended?
Works as planned.
Just a few remarks for the new TZMemTable component:
- ftMemo, ftString, ftFixedChar will throw a nullpointer exception upon opening:
Code: Select all
ZMemTable1.FieldDefs.Add('MyField', ftString);
ZMemTable1.Open;
Code: Select all
else if Current.DataType in [ftMemo, ftString, ftFixedChar] then
ColumnInfo.ColumnCodePage := GetTransliterateCodePage(Connection.ControlsCodePage)
Code: Select all
else if Current.DataType in [{$IFDEF WITH_FTWIDEMEMO}ftWideMemo, {$ENDIF}
ftWideString{$IFDEF WITH_FTFIXEDWIDECHAR}, ftFixedWideChar{$ENDIF}, ftMemo, ftString, ftFixedChar] then
ColumnInfo.ColumnCodePage := zCP_UTF16;
- The above also renders the condition in : 217 useless, as it will never be true:
Code: Select all
if (Connection <> nil) and (Connection.Connected)
then AConSettings := Connection.DbcConnection.GetConSettings
With that said, I have the following code:
Code: Select all
ZMemTable1.FieldDefs.Add('MyField', ftString);
ZMemTable1.Open;
ZMemTable1.Append;
ZMemTable1.FieldByName('MyField').AsString := 'Hello, world!';
ZMemTable1.Post;
The reason is, ConvertDbcToDatasetType sets the fieldtype as WideMemo, if there is no length specified. I can see the reason, just want to ask if it is intended?
Code: Select all
ZMemTable1.FieldDefs.Add('MyField', ftString, 200);