Bonjour
je suis en train de créer une application en C# utilisant une base de données Access.
Or quand je clique sur le bouton "ajouter", j'ai l'erreur suivante:
An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll
Additional information: La colonne 'Numéro PI' n'appartient pas à la table .Or j'ai bien vérifier, il y'a bien cette colonne dans la base de données... .
Je vous laisse le code de la fenêtre concerner:
**********************************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.Common;
namespace WindowsFormsApplication2
{
public partial class Modification : Form
{
OleDbConnection ADONetConnection = new OleDbConnection();
OleDbDataAdapter DataAdapter;
DataTable Switchs = new DataTable();
int rowPosition = 0;
public Modification()
{
InitializeComponent();
}
private void Modification_Load(object sender, EventArgs e)
{
// TODO : cette ligne de code charge les données dans la table 'switchscruasDataSet.Switchs'. Vous pouvez la déplacer ou la supprimer selon vos besoins.
this.switchsTableAdapter.Fill(this.switchscruasDataSet.Switchs);
}
private void Supprimer_Click(object sender, EventArgs e)
{
// Supression de la ligne courante.
if (Switchs.Rows.Count != 0)
{
Switchs.Rows[rowPosition].Delete();
DataAdapter.Update(Switchs);
rowPosition = 0;
this.ShowCurrentRecord();
}
}
private void ShowCurrentRecord()
{
}
private void Changement_Click(object sender, EventArgs e)
{
}
private void Ajout_Click(object sender, EventArgs e)
{
DataRow drNewRow = Switchs.NewRow();
drNewRow["Numéro PI"] = "";
drNewRow["Adresse MAC"] = "";
drNewRow["Switch"] = "";
drNewRow["Lieu"] = "";
Switchs.Rows.Add(drNewRow);
DataAdapter.Update(Switchs);
rowPosition = Switchs.Rows.Count +1;
this.ShowCurrentRecord();
}
private void Quitter_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}************************************************************************
Merci pour votre aide