Bonjour à tous,
je rencontre en ce moment un ptit problème, j'ai une application windows form, et je souhaiterais remplir un datagridview depuis un dataset rempli par une requête vers une base ACCESS 2007, seulement, ayant tout fait bien, je n'arrive pas à parvenir à mes fins...
La requête doit jouer, car quand je met une requête simple comme "select * from [unetable];" aucune exception n'est levée mais le gridview est ... vide...
Voilà mon code:
Merci d'avance, je pense pas avoir oublié quelque chose pourtant...
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 OleDbConnection oConnection; string sConnectionString; OleDbDataAdapter adapter; ... private void load_data() { oConnection = new OleDbConnection(); sConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\mabase.accdb;Persist Security Info=false"; oConnection.ConnectionString = sConnectionString; OleDbCommand command = new OleDbCommand(); command = oConnection.CreateCommand(); DataSet ds = new DataSet(); command.CommandText = "select * from matable;"; try { oConnection.Open(); } catch (Exception ex) { MessageBox.Show("Impossible d'ouvrir la connexion:\n\n" + ex); oConnection.Close(); Application.Exit(); } OleDbDataAdapter adapter = new OleDbDataAdapter(); adapter = new OleDbDataAdapter(command); adapter.Fill(ds); oConnection.Close(); dataGridView_fi.DataSource = ds.Tables[0]; }
Quand la requête est la vrai (celle que je veux, qui est longue), voilà l'erreur:
Oledbexception: aucune valeur donnée pour un ou plusieurs des paramètres requis.
à
Eledbcommand.executeTextErrorHandling(oledbHResult hr)
à
EledbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbparams, Object& executeResult)
à
...
à
...
à
...
à
...
etc..
Partager