How can I display a list of data from database in a messagebox with c#?

I’m using WinForms and c#, and I want to display the list of employees with an expiry card date. I have tried the code below:

DataManager.NotificationManager obj = new DataManager.NotificationManager();
DataTable dt1 = obj.GetListExpiryDate();
DateTime currendate = DateTime.Today;

foreach (DataRow row in dt1.Rows)
    if (DateTime.Parse(row.ItemArray[41].ToString()) == currendate)
        MessageBox.Show("Expired carte for the employee" + row["EmpFName"]);

My stored procedure:

CREATE PROCEDURE [dbo].[GetListExpiryDate]  
    SELECT *    
    FROM MST_Employee  

I need to display the list of the employees with expiry card date in the messagebox, but the problem it that only displays the first one. Any ideas please?

Source: .net

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.