1 (edited by prahousefamily 2018-10-18 00:20:49)

Topic: How To DIsplay StringList.text in TableGrid

I try create  Example  MySQL "Show Create Table mysql.xxx"
And generate DDL All Table  in database insert column ddl
when copy row and paste in NOTEPAD IT OK Show Full Content
But TableGrid Not display same like NOTEPAD
How To Show  ?

Open Code Fix 201810-18

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
i : Integer ;
result : Tdataset;
ddl : Tstringlist;
begin
    Form1.TableGrid1.dbSQL :=
    ' USE mysql ;' + #13#10 +
    ' SELECT TABLE_NAME,NULL AS DDL  FROM information_schema.TABLES ' + #13#10 +
    ' WHERE TABLE_SCHEMA = ''mysql'' ORDER BY TABLE_NAME ;';
    Form1.TableGrid1.dbSQLExecute ;
    ddl := Tstringlist.Create ;
    For i := 0 To Form1.TableGrid1.RowCount -1 Do
    Begin
        Begin
            SQLQuery('Show Create Table '+Form1.TableGrid1.Cells[0,i] ,result);
            ddl.Add(result.Fields[1].AsString);
            ddl.Commatext;
            Form1.TableGrid1.Cells[1,i] := ddl.Text;
        End;
        ddl.clear;
        result.Free;
    End;
    Form1.TableGrid1.BestFitColumns(bfboth);
    Form1.TableGrid1.BestFitRow(1) ;
end;
begin
end.

https://image.ibb.co/eJa7bL/2018-10-17-001.png

Post's attachments

Attachment icon DDL.zip 4.58 kb, 335 downloads since 2018-10-17 

My Visual Database : I Love You
Easy For Beginner Student For Me

Re: How To DIsplay StringList.text in TableGrid

Check it out

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
    i : Integer ;
    result : Tdataset;
begin
    Form1.TableGrid1.dbSQL :=
    ' USE mysql ;' + #13#10 +
    ' SELECT TABLE_NAME, "DDL" FROM information_schema.TABLES ' + #13#10 +
    ' WHERE TABLE_SCHEMA = ''mysql'' ORDER BY TABLE_NAME ;';
    Form1.TableGrid1.dbSQLExecute ;

    For i := 0 To Form1.TableGrid1.RowCount -1 Do
    Begin
        SQLQuery('Show Create Table '+Form1.TableGrid1.Cells[0,i], result);
        Form1.TableGrid1.Cells[1,i] := result.Fields[1].AsString;// ddl.Text;
        result.Free;
    End;

    Form1.TableGrid1.BestFitColumns(bfboth);
end;
Dmitry.

Re: How To DIsplay StringList.text in TableGrid

Thank You Dmitry. It Work ...
Easy Code  And View Use

My Visual Database : I Love You
Easy For Beginner Student For Me