1 (edited by prahousefamily 2018-11-01 05:42:01)

Topic: Example Progressbar ,Dataset, MySQL Show Create Table All

Knowledge In This Example
- MySQl SQL Syntax,
    "Show tables"
    "Show Create Table xxx"
- Tdaset : use loop auto generate ddl in table result
    Concat("Show tables","Show Create Table xxx")
- Tprogressbar
    show status countdown all process
- Event Script Combobox
    select database name for result

Happy Everybody MVD!

Screen Shot
https://image.ibb.co/iYpGnf/2018-11-01-004.png
Open Code

var
progressbar : Tprogressbar ;
procedure Form1_OnShow (Sender: TObject; Action: string);
Var
Q : TDataSet ;
begin
    SQLQuery('Show Databases ',Q);
    Form1.Combobox1.Clear;
    while not Q.Eof do begin
        Form1.Combobox1.Items.Add(Q.Fields.Fields[0].AsString);
        Q.Next;
    end;
    Q.Close;
end;
procedure Form1_ComboBox1_OnChange (Sender: TObject);
begin
    Form1.TableGrid1.dbSQL :=
    ' USE '+Form1.ComboBox1.Text +' ;' + #13#10 +
    ' SELECT TABLE_NAME, "DDL" FROM information_schema.TABLES ' + #13#10 +
    ' WHERE TABLE_SCHEMA = "'+Form1.ComboBox1.Text +'" ORDER BY TABLE_NAME ;';
    Form1.TableGrid1.dbSQLExecute ;
    Form1.Label3.Caption := 'Gen Table List 0 From '+ IntToStr(Form1.TableGrid1.RowCount) ;
    Form1.Label4.Caption := 'Progress '+'0.00 %' ;
end;
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
i : Integer ;
result : Tdataset;
begin
    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;
        Form1.Label3.Caption := 'Gen Table List '+inttostr(i+1)+' From '+ IntToStr(Form1.TableGrid1.RowCount) ;
        Form1.Label4.Caption := 'Progress '+FormatFloat('0.00',(i+1)/(Form1.TableGrid1.RowCount)*100)+' %' ;
        progressbar.position :=  StrToInt(FormatFloat('0',(i+1)/(Form1.TableGrid1.RowCount)*100)) ;
        Application.ProcessMessages;
        result.Free;
    End;
    Form1.TableGrid1.BestFitColumns(bfboth);
    ShowMessage('OK!');
end;
begin
    progressbar := Tprogressbar.Create(Form1) ;
    progressbar.Parent := Form1.Panel1 ;
    progressbar.Align  := AlClient;
    progressbar.Min := 0;
    progressbar.max := 100;
    progressbar.position := 0 ;
end.
Post's attachments

Attachment icon Example GenDDL.zip 328.4 kb, 514 downloads since 2018-11-01 

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

Re: Example Progressbar ,Dataset, MySQL Show Create Table All

Thank you!

Dmitry.