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

VB.NET Discussion :

Insertion dans 2 tables Acess


Sujet :

VB.NET

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2011
    Messages
    61
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2011
    Messages : 61
    Par défaut Insertion dans 2 tables Acess
    Bonjour,

    J'ai (encore) un problème d'insertion de données sur une base Access. J'aimerais pouvoir insérer 2 tables en même Temps (CONFIG et USERS_CONFIG). Une de ces tables (USERS_CONFIG) me sert d'association entre ma table (USERS et USERS_CONFIG). Je transmets un screen pour mieux comprendre.

    J'arrive à insérer dans la table CONFIG mais pas dans USERS_CONFIG.

    Voila le code affecté à mon bouton "Ajouter".

    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
            Dim sql_ajouter_poste As String
            Dim sql_ajouter_user_config As String
            Dim j As Integer
            sql_ajouter_user_config = "INSERT INTO USERS_CONFIG (ASSET,ALPS,DATE_DEBUT_ASSET,ASSET_EN_COURS,COMMENTAIRES_ASSET) VALUES (Val_ASSET, Val_ALPS, Val_DATE_DEBUT_ASSET, Val_ASSET_EN_COURS, Val_COMMENTAIRES_ASSET)"
            sql_ajouter_poste = "INSERT INTO CONFIG (ASSET,TYPE,DATE_DE_LIVRAISON,PRET_POSSIBLE,LIBRE_SERVICE) VALUES (Val_ASSET, Val_TYPE, Val_DATE_DE_LIVRAISON, Val_PRET_POSSIBLE, Val_LIBRE_SERVICE)"
     
            Dim type_config As New TextBox
            Dim en_cours As New CheckBox
            Dim date_day As New DateTimePicker
     
            date_fin.Text = date_fin.MaxDate
     
            For j = 0 To dts_config.Tables("CONFIG").Rows.Count - 1
                If TXT_ASSET.Text = dts_config.Tables("CONFIG").Rows(j).Item("ASSET") Then
                    MsgBox("Poste déja existant")
                    Exit Sub
                End If
            Next
     
            If RB_FIXE.Checked = True Then
                type_config.Text = "FIXE"
            End If
            If rb_portable.Checked = True Then
                type_config.Text = "PORTABLE"
            End If
            If RB_STATION.Checked = True Then
                type_config.Text = "WORKSTATION"
            End If
     
     
            commande_config = New OleDb.OleDbCommand(sql_ajouter_poste, con_config)
     
            commande_config.Parameters.AddWithValue("Val_ASSET", TXT_ASSET.Text)
            commande_config.Parameters.AddWithValue("Val_TYPE", type_config.Text)
            commande_config.Parameters.AddWithValue("Val_DATE_DE_LIVRAISON", DT_Dentre_config.Text)
            commande_config.Parameters.AddWithValue("Val_LIBRE_SERVICE", CHK_LIBRE_SERVICE.Checked)
            commande_config.Parameters.AddWithValue("Val_PRET_POSSIBLE", CHK_PRET.Checked)
     
            dta_config.Update(dts_config, "CONFIG")
     
            dtt_config = dts_config.Tables("CONFIG")
            commande_config.ExecuteReader()
            commande_config.Connection.Close()
            demarrage_config()
     
     
            commande_user_config = New OleDb.OleDbCommand(sql_ajouter_user_config, con_user_config)
     
            commande_user_config.Parameters.AddWithValue("Val_ASSET", TXT_ASSET.Text)
            commande_user_config.Parameters.AddWithValue("Val_ALPS", TXT_ALPS_USER.Text)
            commande_user_config.Parameters.AddWithValue("Val_DATE_DEBUT_ASSET", DT_Dentre_config.Text)
            commande_user_config.Parameters.AddWithValue("Val_DATE_FIN_ASSET", date_fin.Text)
     
            If TXT_COM_CONFIG.Text = "" Then
                commande_user_config.Parameters.AddWithValue("Val_COMMENTAIRES_ASSET", System.DBNull.Value)
            Else
                commande_user_config.Parameters.AddWithValue("Val_COMMENTAIRES_ASSET", TXT_COM_CONFIG.Text)
            End If
     
            dta_user_config.Update(dts_user_config, "USERS_CONFIG")
            dta_user_config.Fill(dts_user_config, "USERS_CONFIG")
            dtt_user_config = dts_user_config.Tables("USERS_CONFIG")
     
            MsgBox("Le poste a bien été ajouté")
     
            demarage_user_config()
     
        End Sub
    Si quelqu'un peut m'aider, je lui en serai reconnaissant.

    Merci par avance.
    Images attachées Images attachées  

Discussions similaires

  1. [ZEOSLIB] Problème Insertion dans une table
    Par moscovisci dans le forum Bases de données
    Réponses: 1
    Dernier message: 09/06/2005, 12h05
  2. [interbase6]probleme d'insertion dans une table
    Par macadam314 dans le forum Bases de données
    Réponses: 10
    Dernier message: 22/02/2005, 14h21
  3. [Sybase] Temps d'une insertion dans une table
    Par vsavoir dans le forum Décisions SGBD
    Réponses: 5
    Dernier message: 14/02/2005, 10h04
  4. Extraction d'un .txt et Insertion dans une table
    Par PoPmiSiR dans le forum Access
    Réponses: 8
    Dernier message: 28/10/2004, 19h13
  5. Détection insertion dans une Table
    Par abelman dans le forum MS SQL Server
    Réponses: 5
    Dernier message: 06/07/2004, 14h24

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