Im trying to fill listView1
with the first table of my database. But it is not working, can someone help me?
The function LoadList
is not recognizing the DataTable DT
Here is the code I am using
namespace Project.Data_Layer
{
class Leerling
{
public static DataTable ExecSelect(string Leerling)
{
DataSet DS = new DataSet();
SqlDataAdapter DA;
DA = new SqlDataAdapter(Leerling, SQLString.Conn);
DS.Clear();
DA.Fill(DS);
// 1e tabel uit database
DataTable DT = DS.Tables[0];
return DT;
}
public static bool ExecOverig(string Leerling)
{
bool gelukt = true;
SqlConnection Connect = new SqlConnection(SQLString.Conn);
SqlCommand Cmd = new SqlCommand(Leerling, Connect);
try
{
Cmd.Connection.Open();
Cmd.ExecuteNonQuery();
Connect.Close();
}
catch
{
gelukt = false;
}
return gelukt;
}
public void LoadList()
{
if(DT.tables.count > 0)
{
listView1.DataSource = DT;
listView1.DataBind();
}
else
{
//
}
}
}
}