Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello friends,

I am creating an application which has one task and that is to show multiple patient birthday reminders.
That means reminders should show multiple patient names on that particular date.
Patient name should show like comma separated in one label, suppose 17/01/2013 is the birthday off two patient then it should show like Happy Birthday to "John, Ricky".
I hope you are getting my point what I am actually trying to say I wrote this code in form load, but it not working.
C#
con = new SqlConnection("Data Source=ADMIN\\SQLEXPRESS;Initial Catalog=PhysioCure; Integrated Security=true");
            con.Open();
            DateTime dtmain = System.DateTime.Now;
            cmd = new SqlCommand("select PationName,ContactNo from Physio_cureTable where DateOfBirth like '" + dtmain.Date.ToString().Substring(0, 5) + "%'", con);
            SqlDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                label18.Name = reader.GetInt32(0).ToString();
                label18.Text = reader.GetString(3).ToUpper();
                label19.Text = reader.GetString(5).ToUpper();

            }
            reader.Close();
            con.Close();
Posted
Updated 16-Jan-13 20:32pm
v3
Comments
Sandeep Mewara 17-Jan-13 2:04am    
What is the code for? How you plan and want to create reminder? Be more specific.
Atul Rokade 17-Jan-13 2:10am    
Sandeep sir i want to show Birthday reminder in my application and that code for im trying birthday reminder bt it wont work , actually i want to show members name on there birthday date

1 solution

1. Your select statement returns 2 columns. While reading, you assume it has 6 (Your index goes till 5).
2. You are setting Name property for label18. You should be setting Text property.
3. You need to append names to Text property. Current logic will display only the last name.
4. You are using dates as string in your application. This is not correct. There is a DateTime datatype and you must use it.
 
Share this answer
 
Comments
Atul Rokade 17-Jan-13 2:33am    
ok danish sir i'll try n let me tell u afterwards thnx for suggestion
Atul Rokade 18-Jan-13 9:27am    
sir iam tried that but not working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900