Base donnée acess

cs_fayrous Messages postés 48 Date d'inscription lundi 23 février 2009 Statut Membre Dernière intervention 30 avril 2009 - 13 avril 2009 à 22:42
krimog Messages postés 1860 Date d'inscription lundi 28 novembre 2005 Statut Membre Dernière intervention 14 février 2015 - 14 avril 2009 à 12:14
Salut;
pouvez vous,S.V.P, me donner une méthode pour récupérer des données de la base
moi j'ai essayé comme ça :
private DataTable get_data(string sql)
{

OleDbConnection conn = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" + Application.StartupPath + "\\bd1.mdb");
OleDbDataAdapter da = new OleDbDataAdapter(sql, conn);
DataSet ds = new DataSet();
conn.Open();
try
{

da.Fill(ds, "x");
return ds.Tables["x"];
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
return ds.Tables["x"];
}
finally
{
conn.Close();
}

}


textBox_note.Text get_data("select correction from Question where and section ' " + "textBox_section_c.Text" + " ' and titre=' " + "textBox_titre_c.Text" + "' and num_exercice ='" + " textBox_exercice_c.Text" + "' and num_question ='" + " textBox_question_c.Text" + "' ; ").Rows[0][0].ToString();

mais cela ne m'affiche pas le résultat
pouvez vous m'aider
merci d'avance

1 réponse

krimog Messages postés 1860 Date d'inscription lundi 28 novembre 2005 Statut Membre Dernière intervention 14 février 2015 49
14 avril 2009 à 12:14
C'est normal que le code soit, à la virgule près, le même code que
http://www.csharpfr.com/forum/sujet-RECUPERATION-DONNEES_1296743.aspx ?
Krimog :
while (!(succeed = try())) ;
0
Rejoignez-nous