Salut,
J'ai ecris une fonction qui cherche dans une base donnee et me retourne le result.
Cette derniere marche tres bien a defaut d ajouter "where". La requete ne me retourne aucun enregistrement.
Par contre si je remplace Label1.Text par 'france' ca marche parfaitement.
C'est quoi le probleme?
Le code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 string ConnStr = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=mydb;uid=root;pwd=;option=3"; using (OdbcConnection con = new OdbcConnection(ConnStr)) using (OdbcCommand cmd = new OdbcCommand("SELECT name FROM societe where pays = @Label1.Text", con)) { con.Open(); DataGrid1.DataSource = cmd.ExecuteReader( CommandBehavior.CloseConnection | CommandBehavior.SingleResult); DataGrid1.DataBind(); }
Partager