I have a couple of questions on how to go creating columns in a NextGrid from a dataset:
1. Is there a two-column list that maps NextGrid column types to compatible Delphi datatypes, eg. "TNxTextColumn = String", "TNxCheckBoxColumn = String, Boolean", "TNxNumberColumn = Integer, Double", etc.?
2. Is there a simple way to display the datatype returned by the dataset, and create a compatible column in a grid?
Here's the current code:
CODE
ASQLite3Query1.SQL.Text := 'SELECT * FROM mytable';
ASQLite3Query1.Open;
for mycol := 0 to ASQLite3Query1.FieldCount - 1 do begin
//======== The quick way to see how wrapper maps SQLite to Delphi
//E2250 There is no overloaded version of 'IntToStr' that can be called with these arguments
//ShowMessage(IntToStr(ASQLite3Query1.Fields[mycol].DataType));
//E2089 Invalid typecast
//ShowMessage(String(ASQLite3Query1.Fields[mycol].DataType));
//======== The longer way...
case ASQLite3Query1.Fields[mycol].DataType of
ftString:
Columns.Add(TNxTextColumn,'My Col1');
ftSmallint:
Columns.Add(TNxNumberColumn,'My Col1');
ftInteger:
Columns.Add(TNxNumberColumn,'My Col1');
ftWord:
Columns.Add(TNxNumberColumn,'My Col1');
etc.
else
ShowMessage('Other type');
end;
end;
ASQLite3Query1.Open;
for mycol := 0 to ASQLite3Query1.FieldCount - 1 do begin
//======== The quick way to see how wrapper maps SQLite to Delphi
//E2250 There is no overloaded version of 'IntToStr' that can be called with these arguments
//ShowMessage(IntToStr(ASQLite3Query1.Fields[mycol].DataType));
//E2089 Invalid typecast
//ShowMessage(String(ASQLite3Query1.Fields[mycol].DataType));
//======== The longer way...
case ASQLite3Query1.Fields[mycol].DataType of
ftString:
Columns.Add(TNxTextColumn,'My Col1');
ftSmallint:
Columns.Add(TNxNumberColumn,'My Col1');
ftInteger:
Columns.Add(TNxNumberColumn,'My Col1');
ftWord:
Columns.Add(TNxNumberColumn,'My Col1');
etc.
else
ShowMessage('Other type');
end;
end;
Thank you.