[débutant] affichage datagrid a partir d'un fichier access
salut,
Je débute en C# et j'ai un peu de mal à faire ce tuto : http://www.c-sharpcorner.com/UploadF.../DataGrid.aspx
J'ai créer un petit fichier access avec une table contact pour tester.
Malheureusement mon code n'affiche pas le contenu de ma table
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
private void data_Load(object sender, System.EventArgs e)
{
// create a connection string
string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=P:\\contacts.mdb";
OleDbConnection myConnection = new OleDbConnection();
myConnection.ConnectionString = connString;
// create a data adapter
OleDbDataAdapter da = new OleDbDataAdapter("Select * from Contacts", myConnection);
// create a new dataset
DataSet ds = new DataSet();
// fill dataset
da.Fill(ds, "Contacts");
// Attach DataSet to DataGrid
dataGrid1.DataSource = ds.DefaultViewManager; |
Merci pour votre aide