Erreur : SqlException n'a pas eté gérée

Résolu
wijdene - 15 nov. 2013 à 22:11
jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 - 16 nov. 2013 à 01:21
Bonjour,
sur la ligne , var red = cmd.ExecuteReader();
voici mon code :
using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Collections;



namespace Soutenance
{
class Connction
// Data Source=Wejden;Initial Catalog="PROJET PFE";Integrated Security=True
{
private String connction = "Data Source=Wejden;Initial Catalog=PROJET PFE;Integrated Security=True";
/* SqlConnection cn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\GI1.mdf;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
SqlDataReader dr;*/
public ArrayList Getalladmin(int id)
{
using (var con = new SqlConnection(connction))
{
con.Open();
var list = new ArrayList();

string Query = "select*form admin where id=" + id;
using (SqlCommand cmd = new SqlCommand(Query, con))
{
cmd.CommandTimeout =100;
var red = cmd.ExecuteReader();

try
{



while (red.Read())
{
String utilisateur = red.GetString(1);
String login = red.GetString(2);
list.Add(utilisateur);
list.Add(login);
}


}
catch (System.Data.SqlClient.SqlException ex)
{

}
con.Close();
red.Close();
return list;

}
}
}
}



}

1 réponse

jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 344
16 nov. 2013 à 01:21
Bonjour.
Tu as écris form au lieu de FROM
0
Rejoignez-nous