hello, i want to fill a grid with this code, without the WHERE condition my code works fine, but when i try to filter on username, it fails.
I made a Session Username and this is my code:
public ICollection<Aanvraag> GetAllAanvragen()
{
List<Aanvraag> result = new List<Aanvraag>();
using (SqlConnection connection = new SqlConnection(_connectionString))
using (SqlCommand command = new SqlCommand())
{
command.CommandText =
"SELECT VID, State, Begindatum, Einddatum, WorkflowInstanceID, Opmerking, Type, Username FROM tblVerlofaanvraag WHERE Username = 'Session[username].ToString()'";
connection.Open();
command.Connection = connection;
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
result.Add(
Aanvraag.CreateFromDataReader(reader));
}
}
}
return result;
}