IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Bases de données Delphi Discussion :

erreur creation de table firebird


Sujet :

Bases de données Delphi

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    24
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Avril 2006
    Messages : 24
    Points : 22
    Points
    22
    Par défaut erreur creation de table firebird
    bonjour à tous
    lorsque j'execute le code suivant j'ai une erreure Demande annulée par l'utilisateur
    la base ce crée bien par contre les tables non
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    unit UServeur;
    interface
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, JvWizard, JvExControls, JvWizardRouteMapList, StdCtrls,
      JvExStdCtrls, JvListBox, JvDriveCtrls, JvCombobox, IBDatabase, DB,
      IBCustomDataSet, IBQuery;
    type
      TFrm_Serveur = class(TForm)
        JvWizard1: TJvWizard;
        JvWizardWelcomePage1: TJvWizardWelcomePage;
        JvWizardRouteMapList1: TJvWizardRouteMapList;
        Memo1: TMemo;
        GroupBox1: TGroupBox;
        RadioButton1: TRadioButton;
        Dossier: TJvWizardInteriorPage;
        C_Disque: TJvDriveCombo;
        L_Dossier: TJvDirectoryListBox;
        GroupBox2: TGroupBox;
        E_Moniteur: TEdit;
        Base: TJvWizardInteriorPage;
        GroupBox3: TGroupBox;
        M_MoniteurBase: TMemo;
        Btn_Install: TButton;
        IBDatabase: TIBDatabase;
        IBTransaction: TIBTransaction;
        IBQuery: TIBQuery;
        procedure L_DossierChange(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        Procedure Init_DossierInstall;
        Procedure DataBase_Cree;
        Procedure TableClient_Cree;
        procedure Btn_InstallClick(Sender: TObject);
      private
        { Déclarations privées }
      public
        { Déclarations publiques }
      end;
    var
      Frm_Serveur: TFrm_Serveur;
      BasePath : string;
      BaseDirectory : string;
      IBDataBase: TIBDatabase;
      IBQuery: TIBQuery;
      IBTransaction: TIBTransaction;
      implementation
    {$R *.dfm}
    procedure TFrm_Serveur.L_DossierChange(Sender: TObject);
    begin
    Frm_serveur.Init_DossierInstall;
    end;
    procedure TFrm_Serveur.FormCreate(Sender: TObject);
    begin
    Frm_Serveur.Init_DossierInstall;
    end;
    Procedure TFrm_Serveur.Init_DossierInstall;
    begin
    If Frm_serveur.L_Dossier.Directory  = (Frm_serveur.C_Disque.Drive + ':\' ) then
       begin
       Frm_Serveur.E_Moniteur.Text := Frm_Serveur.L_Dossier.Directory + 'GC_Datas\DB_GEST';
       BaseDirectory := Frm_Serveur.L_Dossier.Directory;
       end
    else
        begin
        Frm_Serveur.E_Moniteur.Text := Frm_Serveur.L_Dossier.Directory + '\GC_Datas\DB_GEST';
        BaseDirectory := Frm_Serveur.L_Dossier.Directory+'\'
        end;
    BasePath := Frm_Serveur.E_Moniteur.Text;
    end;
    Procedure TFrm_Serveur.DataBase_Cree;
    begin
    if not DirectoryExists(BaseDirectory+'GC_Datas') then
       begin
       try
          CreateDir(BaseDirectory+'GC_Datas')
          Except
                showmessage('Impossible de créer le Dossier' +#13#10+ BaseDirectory+'GC_Datas !');
       end;
    end;
    If FileExists(BasePath) then showmessage ('La Base De Données' + #13#10 + 'Existe Déjà !!')
    else
        begin
        //Creation de la base de données
        IBDataBase := TIBDatabase.Create(nil);
        IBQuery := TIBQuery.Create(nil);
        IBTransaction := TIBTransaction.Create(nil);
        try
           IBDataBase.DatabaseName := '127.0.0.1:'+BasePath;
           IBDataBase.SQLDialect := 3;
           IBDataBase.Params.Clear;
           IBDataBase.Params.Add('USER "SYSDBA"');
           IBDataBase.Params.Add('PASSWORD "masterkey"');
           IBDataBase.Params.Add('PAGE_SIZE 4096');
           IBDataBase.CreateDatabase;
           IBDatabase.Connected := true;
           IBTransaction.DefaultDatabase := IBDataBase;
           IBQuery.Database := IBDatabase;
           IBQuery.Transaction := IBTransaction;
           try
             IBQuery.SQL.Add('create table IODescriptorEx(IOId int not null,IOFileMask VarChar(30),'+
                                        'AlternativeDesc VarChar(50));');
             IBQuery.ExecSQL;
             IBTransaction.Commit;
             except
               IBTransaction.Rollback;
               ShowMessage ('Erreur !' + #13#10 + 'Le serveur est non fonctionnel !');
           end;
        IBDataBase.Connected := false;
        finally
        FreeAndNil(IBQuery);
        FreeAndNil(IBTransaction);
        FreeAndNil(IBDataBase);
        end;
      end;
    end;
    procedure TFrm_Serveur.Btn_InstallClick(Sender: TObject);
    begin
     Frm_Serveur.DataBase_Cree;
     Frm_Serveur.TableClient_Cree;
    end;
    Procedure TFrm_Serveur.TableClient_Cree;
    begin
    IBDataBase := TIBDatabase.Create(nil);
    IBQuery := TIBQuery.Create(nil);
    IBTransaction := TIBTransaction.Create(nil);
        try
           IBDataBase.DatabaseName := '127.0.0.1:'+BasePath;
           IBDataBase.SQLDialect := 3;
           IBDataBase.Params.Clear;
           IBDataBase.Params.Add('USER "SYSDBA"');
           IBDataBase.Params.Add('PASSWORD "masterkey"');
           IBDataBase.Params.Add('PAGE_SIZE 4096');
           IBDatabase.Connected := true;
           IBTransaction.DefaultDatabase := IBDataBase;
           IBQuery.Database := IBDatabase;
           IBQuery.Transaction := IBTransaction;
           try
             IBQuery.SQL.Add('create table T_Clients');
             IBQuery.SQL.Add('(C_Id INTEGER,');
             Ibquery.SQL.add('C_Code varchar(30),');
             IbQuery.SQL.Add('C_Nom varchar,');
             IbQuery.SQL.Add('C_Adresse1 varchar,');
             IbQuery.SQL.Add('C_Adresse2 varchar,');
             IbQuery.SQL.Add('C_CP varchar(30),');
             IbQuery.SQL.Add('C_Ville varchar,');
             IbQuery.SQL.Add('C_Telephone1 varchar,');
             IbQuery.SQL.Add('C_Telephone2 varchar,');
             IbQuery.SQL.Add('C_Fax varchar,');
             IbQuery.SQL.Add('C_EMail varchar,');
             IbQuery.SQL.Add('C_Internet varchar,');
             IbQuery.SQL.Add('C_Commercial INTEGER,');
             IbQuery.SQL.Add('C_Etat INTEGER,');
             IbQuery.SQL.Add('C_Prospect BOOLEAN,');
             IbQuery.SQL.Add('C_Reg_Mode varchar,');
             IbQuery.SQL.Add('C_Reg_NbJours INTEGER,');
             IbQuery.SQL.Add('C_Reg_Le INTEGER,');
             IbQuery.SQL.Add('C_Reg_Compta varchar,');
             IbQuery.SQL.Add('C_Reg_RIB varchar,');
             IbQuery.SQL.Add('C_Reg_Banque varchar,');
             IbQuery.SQL.Add('C_Reg_Siret varchar,');
             IbQuery.SQL.Add('C_Reg_APE varchar,');
             IbQuery.SQL.Add('C_Reg_TVA varchar,');
             //IbQuery.SQL.Add('C_Notes BLOB,');
             IbQuery.SQL.Add('C_DateCreation varchar,');
             IbQuery.SQL.Add('C_DateModification varchar,');
             IbQuery.SQL.Add('C_CreeParQui INTEGER,');
             IbQuery.SQL.Add('C_ModifieParQui INTEGER);');
             IBQuery.ExecSQL;
             IBTransaction.Commit;
             except
               IBTransaction.Rollback;
               ShowMessage ('Erreur !' + #13#10 + 'Le serveur est non fonctionnel !');
           end;
        IBDataBase.Connected := false;
        finally
        //IBDataBase.Connected := false;
        FreeAndNil(IBQuery);
        FreeAndNil(IBTransaction);
        FreeAndNil(IBDataBase);
        end;
      end;
    end.

  2. #2
    Expert éminent
    Avatar de qi130
    Homme Profil pro
    Expert Processus IT
    Inscrit en
    Mars 2003
    Messages
    3 902
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 63
    Localisation : France

    Informations professionnelles :
    Activité : Expert Processus IT
    Secteur : Finance

    Informations forums :
    Inscription : Mars 2003
    Messages : 3 902
    Points : 6 026
    Points
    6 026
    Par défaut
    Pourquoi la dimension des VARCHAR n'est pas indiquée ?
    "Il n'y a pas de bonnes réponses à une mauvaise question." (M. Godet)
    -----------------------
    Pensez à cloturer votre sujet - Aucune réponse aux sollicitations techniques par MP
    Usus magister est optimus

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    24
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Avril 2006
    Messages : 24
    Points : 22
    Points
    22
    Par défaut
    Un Oubli pour les tests
    Mais c'est toujours pareil

  4. #4
    Membre éprouvé
    Avatar de neilbgr
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Août 2004
    Messages
    651
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2004
    Messages : 651
    Points : 1 177
    Points
    1 177
    Par défaut
    Ce n'est pas parcequ'avec un TIbQuery on ne peut pas modifier une BDD mais faire plutot avec un TIbSQL ?
    "Si vous voulez être l’esclave des banques et payer pour financer votre propre esclavage, alors laissez les banquiers créer la monnaie" - Josiah Stamp, 1920, Gouverneur de la Banque d’Angleterre
    "Qui ne peut acheter ruine qui voudrait vendre" - Jacques Duboin.
    "Nous n'héritons pas la terre de nos parents, nous l'empruntons à nos enfants." - Antoine de Saint Exupéry

  5. #5
    SLE
    SLE est déconnecté
    Membre éclairé Avatar de SLE
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Janvier 2004
    Messages
    604
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Belgique

    Informations professionnelles :
    Activité : Consultant informatique

    Informations forums :
    Inscription : Janvier 2004
    Messages : 604
    Points : 799
    Points
    799
    Par défaut
    Il y a longtemps que je n'ai plus fait de delphi, mais il me semble qu'il ne fallait pas mettre le ; en fin de requête dans le IBQuery...

  6. #6
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    24
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Avril 2006
    Messages : 24
    Points : 22
    Points
    22
    Par défaut
    Idem sans le ; en fin de requete
    Idem avec IBSQL
    argh

  7. #7
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    24
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Avril 2006
    Messages : 24
    Points : 22
    Points
    22
    Par défaut
    En fait c'est la connexion à la base qui pose probleme....
    Mais je ne vois pas pourquoi
    faut il que j'utilise un autre TIBDatabase que celui qui a servi à la créer??
    Pourtant le FreeAndNil(Ibdatabase) lors de la creation de la base me le libere bien????

    je vais me pendre !!!!

  8. #8
    Membre habitué Avatar de Archibald29
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    112
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 112
    Points : 131
    Points
    131
    Par défaut Création Base FireBird
    Bonjour,

    A tout hasard, ne faut il pas activer la transaction ?

    Je vois bien qu'elle est créée :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    IBQuery.Transaction := IBTransaction;
    mais je ne sais pas si elle est créée active par défaut ?


  9. #9
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    24
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Avril 2006
    Messages : 24
    Points : 22
    Points
    22
    Par défaut toujours pareil meme avec ce code
    Bonjour,
    j'ai tout refait ...

    Et avec ce code il me met : " Demande annullée par l'utilisateur " sur le message base impossible à ouvrir : donc dans la 1 ere partie du code
    sur le IBDatabase...
    J'y comprends plus rien
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
     
    Procedure TFrm_Serveur.TableClient_Cree;
    begin
    with IbDatabase, Params do
      begin
        Connected:= False;
        try
        DatabaseName:= '127.0.0.1'+basepath;
        SqlDialect:= 3;
        Clear;
        Add('USER "sysdba"');
        Add('PASSWORD "masterkey"');
        Add('PAGE_SIZE 4096');
        Connected := true;
        showmessage ('hello! master');
        except
        on e: exception do
        showmessage ('base impossible à ouvrir' + e.message); //<-- ICI
        end;
        end;
      with IbQuery do
        begin
          Close;
          with Sql do
          begin
            Clear;
            Add('CREATE TABLE T_Clients');
            add(' (C_Id INTEGER,');
            add(' C_Code varchar(30),');
            Add(' C_Nom varchar(50),');
            Add(' C_Adresse1 varchar(50),');
            Add(' C_Adresse2 varchar(50),');
            Add(' C_CP varchar(30),');
            Add(' C_Ville varchar(50),');
            Add(' C_Telephone1 varchar(50),');
            Add(' C_Telephone2 varchar(50),');
            Add(' C_Fax varchar(50),');
            Add(' C_EMail varchar(50),');
            Add(' C_Internet varchar(50),');
            Add(' C_Commercial INTEGER,');
            Add(' C_Etat INTEGER,');
            Add(' C_Prospect BOOLEAN,');
            Add(' C_Reg_Mode varchar(50),');
            Add(' C_Reg_NbJours INTEGER,');
            Add(' C_Reg_Le INTEGER,');
            Add(' C_Reg_Compta varchar(50),');
            Add(' C_Reg_RIB varchar(50),');
            Add(' C_Reg_Banque varchar(50),');
            Add(' C_Reg_Siret varchar(50),');
            Add(' C_Reg_APE varchar(50),');
            Add(' C_Reg_TVA varchar(50),');
            //Add('C_Notes BLOB,');
            Add(' C_DateCreation varchar(50),');
            Add(' C_DateModification varchar(50),');
            Add(' C_CreeParQui INTEGER,');
            Add(' C_ModifieParQui INTEGER)');
            //Add(' ;');
            end; // with Sql
            Try
            IbDatabase.Open;
            if IbDatabase.DefaultTransaction.Active
            then Showmessage('active')
            else Showmessage('closed');
            //display('Commit_previous');
            if ibtransaction1.InTransaction
            then ibTransaction1.Commit;
            showmessage ('StartTransaction');
            ibtransaction1.StartTransaction;
            if IbDatabase1.DefaultTransaction.Active
            then Showmessage('active')
            else Showmessage('closed');
            ShowMessage(SQL.Text );
            ExecSql;
            //display('Commit');
            ibtransaction1.Commit;
            ShowMessage('  ok');
            except
            on e: Exception do
            ShowMessage('  *** pb_create '+ e.Message);
            end;
         end;
      end;

  10. #10
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    24
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Avril 2006
    Messages : 24
    Points : 22
    Points
    22
    Par défaut Trouvé : c'est le champs boolean


    Merci à tous
    Je passe le sujet resolu

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 6
    Dernier message: 21/11/2013, 09h52
  2. Erreur de filtre sur une table Firebird
    Par defluc dans le forum Bases de données
    Réponses: 8
    Dernier message: 05/06/2010, 11h22
  3. Erreur 145 sur table mysql
    Par ramses83 dans le forum Requêtes
    Réponses: 1
    Dernier message: 06/09/2007, 21h09
  4. creation de table d'erreurs
    Par rikau2 dans le forum C++
    Réponses: 12
    Dernier message: 18/07/2007, 19h34
  5. Réponses: 1
    Dernier message: 20/07/2006, 15h42

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo