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

Windows Forms Discussion :

[VB.NET] Problème étrange lors de la création de BDD


Sujet :

Windows Forms

  1. #1
    Membre à l'essai
    Inscrit en
    Mai 2004
    Messages
    25
    Détails du profil
    Informations forums :
    Inscription : Mai 2004
    Messages : 25
    Points : 15
    Points
    15
    Par défaut [VB.NET] Problème étrange lors de la création de BDD
    Salut.
    Je doit créer une petite BDD dans mon projet sous VB.NET 2003. Je crée donc mes contraintes de clé primaire, puis celles de clés étrangères sur la base. Les FK sont bien reportées sur les tables étant donné que je les met en mode cascade. Jusque là, tout va bien. Le problème c'est que quand j'exécute le code (pour l'instant il n'y a que la BDD), j'ai droit à une exception me disant en gros qu'il y a plusieurs contraintes de nom "Constraint1". Le truc c'est que j'ai bien nommé toutes mes contraintes, et que j'ai revérifié tout le code généré automatiquement ... et pas de trace de "Constraint1" ! Encore plus étrange, lorsque je ferme le projet et que je le réouvre, mes contraintes ont bien gardé leurs noms dans le code, mais si je vais les voir à partir de l'éditeur (maBDD > proriétés > maTable > constraints), toutes mes primary keys ont le nom "Constraint1" ! Je ne comprend vraiment pas d'où ça vient... C'est moi ou c'est VB qui fait quelque chose de travers : : :

  2. #2
    Membre expert
    Avatar de trotters213
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    2 571
    Détails du profil
    Informations personnelles :
    Âge : 38
    Localisation : France, Gard (Languedoc Roussillon)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 2 571
    Points : 3 145
    Points
    3 145
    Par défaut

    tu peux nous montrer ta base et le message d'erreur :

  3. #3
    Membre à l'essai
    Inscrit en
    Mai 2004
    Messages
    25
    Détails du profil
    Informations forums :
    Inscription : Mai 2004
    Messages : 25
    Points : 15
    Points
    15
    Par défaut
    Voila le bout de code pour la BDD (j'avais viré les FK entre temps) :

    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
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
     
     '
            'BDD
            '
            Me.BDD.DataSetName = "NewDataSet"
            Me.BDD.Locale = New System.Globalization.CultureInfo("fr-FR")
            Me.BDD.Tables.AddRange(New System.Data.DataTable() {Me.DT_comptes, Me.DT_proprio, Me.DT_operation, Me.DT_tiers, Me.DT_categ, Me.DT_auto})
            '
            'DT_comptes
            '
            Me.DT_comptes.Columns.AddRange(New System.Data.DataColumn() {Me.DC_co_id, Me.DC_co_proprio, Me.DC_co_com})
            Me.DT_comptes.Constraints.AddRange(New System.Data.Constraint() {New System.Data.UniqueConstraint("PK_comptes", New String() {"co_id"}, True)})
            Me.DT_comptes.PrimaryKey = New System.Data.DataColumn() {Me.DC_co_id}
            Me.DT_comptes.TableName = "comptes"
            '
            'DC_co_id
            '
            Me.DC_co_id.AllowDBNull = False
            Me.DC_co_id.AutoIncrement = True
            Me.DC_co_id.Caption = "ID"
            Me.DC_co_id.ColumnName = "co_id"
            Me.DC_co_id.DataType = GetType(System.Int32)
            '
            'DC_co_proprio
            '
            Me.DC_co_proprio.AllowDBNull = False
            Me.DC_co_proprio.Caption = "Propriétaire"
            Me.DC_co_proprio.ColumnName = "co_proprio"
            Me.DC_co_proprio.DataType = GetType(System.Int32)
            '
            'DC_co_com
            '
            Me.DC_co_com.AllowDBNull = False
            Me.DC_co_com.Caption = "Nom"
            Me.DC_co_com.ColumnName = "co_com"
            '
            'DT_proprio
            '
            Me.DT_proprio.Columns.AddRange(New System.Data.DataColumn() {Me.DC_pr_id, Me.DC_pr_nom, Me.DC_pr_mdp})
            Me.DT_proprio.Constraints.AddRange(New System.Data.Constraint() {New System.Data.UniqueConstraint("PK_proprio", New String() {"pr_id"}, True)})
            Me.DT_proprio.PrimaryKey = New System.Data.DataColumn() {Me.DC_pr_id}
            Me.DT_proprio.TableName = "proprio"
            '
            'DC_pr_id
            '
            Me.DC_pr_id.AllowDBNull = False
            Me.DC_pr_id.AutoIncrement = True
            Me.DC_pr_id.Caption = "ID"
            Me.DC_pr_id.ColumnName = "pr_id"
            Me.DC_pr_id.DataType = GetType(System.Int32)
            '
            'DC_pr_nom
            '
            Me.DC_pr_nom.AllowDBNull = False
            Me.DC_pr_nom.Caption = "Nom"
            Me.DC_pr_nom.ColumnName = "pr_com"
            '
            'DC_pr_mdp
            '
            Me.DC_pr_mdp.AllowDBNull = False
            Me.DC_pr_mdp.Caption = "Mot de passe"
            Me.DC_pr_mdp.ColumnName = "pr_mdp"
            Me.DC_pr_mdp.DataType = GetType(System.UInt16)
            '
            'DT_operation
            '
            Me.DT_operation.Columns.AddRange(New System.Data.DataColumn() {Me.DC_op_id, Me.DC_op_compte, Me.DC_op_categ, Me.DC_op_tiers, Me.DC_op_libelle, Me.DC_op_comment, Me.DC_op_date, Me.DC_op_debit, Me.DC_op_credit, Me.DC_op_auto})
            Me.DT_operation.Constraints.AddRange(New System.Data.Constraint() {New System.Data.UniqueConstraint("PK_operation", New String() {"op_id"}, True)})
            Me.DT_operation.PrimaryKey = New System.Data.DataColumn() {Me.DC_op_id}
            Me.DT_operation.TableName = "operation"
            '
            'DC_op_id
            '
            Me.DC_op_id.AllowDBNull = False
            Me.DC_op_id.AutoIncrement = True
            Me.DC_op_id.Caption = "ID"
            Me.DC_op_id.ColumnName = "op_id"
            Me.DC_op_id.DataType = GetType(System.Int32)
            '
            'DC_op_compte
            '
            Me.DC_op_compte.AllowDBNull = False
            Me.DC_op_compte.Caption = "Compte"
            Me.DC_op_compte.ColumnName = "op_compte"
            Me.DC_op_compte.DataType = GetType(System.Int32)
            '
            'DC_op_categ
            '
            Me.DC_op_categ.AllowDBNull = False
            Me.DC_op_categ.Caption = "Categorie"
            Me.DC_op_categ.ColumnName = "op_categ"
            Me.DC_op_categ.DataType = GetType(System.Int32)
            '
            'DC_op_tiers
            '
            Me.DC_op_tiers.AllowDBNull = False
            Me.DC_op_tiers.Caption = "Tiers"
            Me.DC_op_tiers.ColumnName = "op_tiers"
            Me.DC_op_tiers.DataType = GetType(System.Int32)
            '
            'DC_op_libelle
            '
            Me.DC_op_libelle.AllowDBNull = False
            Me.DC_op_libelle.Caption = "Libellé"
            Me.DC_op_libelle.ColumnName = "op_libelle"
            '
            'DC_op_comment
            '
            Me.DC_op_comment.AllowDBNull = False
            Me.DC_op_comment.Caption = "Commentaire"
            Me.DC_op_comment.ColumnName = "op_comment"
            '
            'DC_op_date
            '
            Me.DC_op_date.AllowDBNull = False
            Me.DC_op_date.Caption = "Date"
            Me.DC_op_date.ColumnName = "op_date"
            Me.DC_op_date.DataType = GetType(System.DateTime)
            '
            'DC_op_debit
            '
            Me.DC_op_debit.AllowDBNull = False
            Me.DC_op_debit.Caption = "Débit"
            Me.DC_op_debit.ColumnName = "op_debit"
            Me.DC_op_debit.DataType = GetType(System.Double)
            '
            'DC_op_credit
            '
            Me.DC_op_credit.AllowDBNull = False
            Me.DC_op_credit.Caption = "Crédit"
            Me.DC_op_credit.ColumnName = "op_credit"
            Me.DC_op_credit.DataType = GetType(System.Double)
            '
            'DC_op_auto
            '
            Me.DC_op_auto.AllowDBNull = False
            Me.DC_op_auto.Caption = "Automatique"
            Me.DC_op_auto.ColumnName = "op_auto"
            Me.DC_op_auto.DataType = GetType(System.Boolean)
            '
            'DT_tiers
            '
            Me.DT_tiers.Columns.AddRange(New System.Data.DataColumn() {Me.DC_ti_id, Me.DC_ti_compte, Me.DC_ti_nom})
            Me.DT_tiers.Constraints.AddRange(New System.Data.Constraint() {New System.Data.UniqueConstraint("PK_tiers", New String() {"ti_id"}, True)})
            Me.DT_tiers.PrimaryKey = New System.Data.DataColumn() {Me.DC_ti_id}
            Me.DT_tiers.TableName = "tiers"
            '
            'DC_ti_id
            '
            Me.DC_ti_id.AllowDBNull = False
            Me.DC_ti_id.AutoIncrement = True
            Me.DC_ti_id.Caption = "ID"
            Me.DC_ti_id.ColumnName = "ti_id"
            Me.DC_ti_id.DataType = GetType(System.Int32)
            '
            'DC_ti_compte
            '
            Me.DC_ti_compte.AllowDBNull = False
            Me.DC_ti_compte.Caption = "Compte"
            Me.DC_ti_compte.ColumnName = "ti_compte"
            Me.DC_ti_compte.DataType = GetType(System.Int32)
            '
            'DC_ti_nom
            '
            Me.DC_ti_nom.AllowDBNull = False
            Me.DC_ti_nom.Caption = "Nom"
            Me.DC_ti_nom.ColumnName = "ti_nom"
            '
            'DT_categ
            '
            Me.DT_categ.Columns.AddRange(New System.Data.DataColumn() {Me.DC_ca_id, Me.DC_ca_pere, Me.DC_ca_nom})
            Me.DT_categ.Constraints.AddRange(New System.Data.Constraint() {New System.Data.UniqueConstraint("PK_categ", New String() {"ca_id"}, True)})
            Me.DT_categ.PrimaryKey = New System.Data.DataColumn() {Me.DC_ca_id}
            Me.DT_categ.TableName = "categ"
            '
            'DC_ca_id
            '
            Me.DC_ca_id.AllowDBNull = False
            Me.DC_ca_id.AutoIncrement = True
            Me.DC_ca_id.Caption = "ID"
            Me.DC_ca_id.ColumnName = "ca_id"
            Me.DC_ca_id.DataType = GetType(System.Int32)
            '
            'DC_ca_pere
            '
            Me.DC_ca_pere.Caption = "Père"
            Me.DC_ca_pere.ColumnName = "ca_pere"
            Me.DC_ca_pere.DataType = GetType(System.Int32)
            '
            'DC_ca_nom
            '
            Me.DC_ca_nom.AllowDBNull = False
            Me.DC_ca_nom.Caption = "Nom"
            Me.DC_ca_nom.ColumnName = "ca_nom"
            '
            'DT_auto
            '
            Me.DT_auto.Columns.AddRange(New System.Data.DataColumn() {Me.DC_au_id, Me.DC_au_operation, Me.DC_au_jour, Me.DC_au_toutLes, Me.DC_au_pendant})
            Me.DT_auto.Constraints.AddRange(New System.Data.Constraint() {New System.Data.UniqueConstraint("PK_auto", New String() {"au_id"}, True)})
            Me.DT_auto.PrimaryKey = New System.Data.DataColumn() {Me.DC_au_id}
            Me.DT_auto.TableName = "auto"
            '
            'DC_au_id
            '
            Me.DC_au_id.AllowDBNull = False
            Me.DC_au_id.AutoIncrement = True
            Me.DC_au_id.Caption = "ID"
            Me.DC_au_id.ColumnName = "au_id"
            Me.DC_au_id.DataType = GetType(System.Int32)
            '
            'DC_au_operation
            '
            Me.DC_au_operation.AllowDBNull = False
            Me.DC_au_operation.Caption = "Opération"
            Me.DC_au_operation.ColumnName = "au_operation"
            Me.DC_au_operation.DataType = GetType(System.Int32)
            '
            'DC_au_jour
            '
            Me.DC_au_jour.AllowDBNull = False
            Me.DC_au_jour.Caption = "Le"
            Me.DC_au_jour.ColumnName = "au_jour"
            Me.DC_au_jour.DataType = GetType(System.UInt16)
            '
            'DC_au_toutLes
            '
            Me.DC_au_toutLes.AllowDBNull = False
            Me.DC_au_toutLes.Caption = "Tout les"
            Me.DC_au_toutLes.ColumnName = "au_toutLes"
            Me.DC_au_toutLes.DataType = GetType(System.UInt32)
            '
            'DC_au_pendant
            '
            Me.DC_au_pendant.AllowDBNull = False
            Me.DC_au_pendant.Caption = "Pendant"
            Me.DC_au_pendant.ColumnName = "au_pendant"
            Me.DC_au_pendant.DataType = GetType(System.UInt64)

    Donc la, comme tu vois, pas de trace de "Constraint1" mais si je regarde avec l'éditeur graphique à partir des propriétés du dataset après avoir fermé et réouvert le projet, toutes mes PK ont changé de nom et sont devenues "Constraint1", alors qu'il n'y a aucune modif dans le code source...

  4. #4
    Membre expert
    Avatar de trotters213
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    2 571
    Détails du profil
    Informations personnelles :
    Âge : 38
    Localisation : France, Gard (Languedoc Roussillon)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 2 571
    Points : 3 145
    Points
    3 145
    Par défaut
    Tu utilises quoi comme SGBD : Tu as essayé en rentrant ta base directement dedans avec ce que ça donnait, s tu avais encore le même message d'erreur :

  5. #5
    Membre à l'essai
    Inscrit en
    Mai 2004
    Messages
    25
    Détails du profil
    Informations forums :
    Inscription : Mai 2004
    Messages : 25
    Points : 15
    Points
    15
    Par défaut
    Je n'utilise en fait pas de sgbd vu que la base ne comprendra que peu d'enregistrements. En fait, je rentrerais les infos directement dans le dataset, et la sauvegarde / chargement des infos se fera grâce à un fichier xml que je crypterais. Par contre je n'ai testé que la base vide, je vais voir ce que ça donne si je met quelques enregistrements dedans (on sait jamais...)

  6. #6
    Membre à l'essai
    Inscrit en
    Mai 2004
    Messages
    25
    Détails du profil
    Informations forums :
    Inscription : Mai 2004
    Messages : 25
    Points : 15
    Points
    15
    Par défaut
    Ca y est, j'ai (enfin) réussi à résoudre le problème (bien que la solution me semble aussi étrange que le problème...) En fait, il ne faut pas créer ses clés primaires soi même avant de créer les clés étrangère sinon j'imagine que VB en recrée automatiquement, ce qui écrase les anciennes et cause des problèmes (?). J'ai donc juste mis mes FK, et tout marche très bien. Bizare quand même...

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

Discussions similaires

  1. Probleme Ibquery lors de la création d’une BDD interbase
    Par delrama dans le forum Bases de données
    Réponses: 4
    Dernier message: 23/05/2014, 15h38
  2. Réponses: 3
    Dernier message: 12/03/2010, 13h14
  3. Réponses: 1
    Dernier message: 25/10/2009, 20h26
  4. Réponses: 10
    Dernier message: 13/01/2008, 11h52
  5. Réponses: 1
    Dernier message: 16/07/2007, 09h54

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