Connection de la base donnée

cs_fayrous Messages postés 48 Date d'inscription lundi 23 février 2009 Statut Membre Dernière intervention 30 avril 2009 - 11 avril 2009 à 18:13
mouradking Messages postés 2 Date d'inscription vendredi 13 mars 2009 Statut Membre Dernière intervention 24 avril 2010 - 24 avril 2010 à 01:12
Salut,
le code suivant lors de l'éxécution donne une exception

private DataTable get_data(string sql)
{

OleDbConnection conn = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" + Application.StartupPath + "\\bd2.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();
}
}

private void button1_Click(object sender, EventArgs e)
{
DateTime p = dateTimePicker1.Value;
string tt = get_data("select titre from Question where date= '" + p + "' ").ToString();
textBox1.Text = tt;
}


}
S.V.P pouvez vous m'expliquer pourquoi pour mieux comprendre.
merci d'avance.

1 réponse

mouradking Messages postés 2 Date d'inscription vendredi 13 mars 2009 Statut Membre Dernière intervention 24 avril 2010
24 avril 2010 à 01:12
coucou tu na pas le droit de convertir un
DataTable
en
String
(ce n'est pas logique)
car ta fonction get_data () retourne un
DataTable

cherche dans le frum cette convertion
enjoy
a+
0
Rejoignez-nous