Einzelnen Beitrag anzeigen

question

Registriert seit: 17. Apr 2013
97 Beiträge
 
#1

Create Database and Table at runtime

  Alt 6. Okt 2013, 13:52
Datenbank: mysql • Version: 5.0 • Zugriff über: Delphi
Hi,
I would like to create Database and table in runtime, i have used Datamodule component and created two procedure, Procedure CreateDB; Procedure CreateTB;

Code:
Procedure CreateDB;
begin
// I would like to test if the "TestDB" not Exist then i would like to create the DataBase "TestDB"
End;

procedure TDataModule1.CreateTB;
begin
//I would like to check first if the table " titles" not exist then i would like to create this table
  Query1.Close;
  Query1.SQL.Add('CREATE TABLE titles(
  Query1.SQL.Add(' emp_no     INT         NOT NULL,');
  Query1.SQL.Add('title      VARCHAR(50) NOT NULL,');
  Query1.SQL.Add(' from_date  DATE        NOT NULL, ');
  Query1.SQL.Add('to_date    DATE,');
  Query1.SQL.Add(' Primary KEY        (emp_no),');
  Query1.ExecSQL;

end;
can anybody help me please?
  Mit Zitat antworten Zitat