Click here to Skip to main content
15,902,635 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i have two access db tables userdata and arear. userdata contains uid,firstname,lastname,address,reg_date while arear contain uid,jan,feb,mar.
what i want is that i click on buton and it takes current date go through the userdata table and get all that record which has the same reg_date(only day/date not month) equal to current day/date, and it also takes data from arear table that has the same uid. i have write some code but i dont understand what i need to do
C#
OleDbConnection connection1 = Manageconnection.Getconnection();
               string query1 = "SELECT * FROM userdata";
               OleDbCommand command = new OleDbCommand(query1, connection1);
               command.CommandType = CommandType.Text;
               OleDbDataReader reader = command.ExecuteReader();

               ArrayList data = new ArrayList();
               while (reader.Read())
               {

                   DateTime time = Convert.ToDateTime(reader[12].ToString());
                   int day = time.Day;
                   int a;
                   a = Convert.ToInt32(DateTime.Now.Day);
                   if (day == a)
                   {

                       Managedata m = new Managedata();


                       string name = reader[0].ToString();
                       string fathername = reader[1].ToString();
                       string nic = reader[2].ToString();
                       string address = reader[3].ToString();
                       string contact = reader[4].ToString();
                       string uiid = reader[6].ToString();
                       string zone = reader[7].ToString();
                       string contaction = reader[8].ToString();

                       m.full_name = name;
                       m.father_name = fathername;
                       m.nic = nic;
                       m.Address = address;
                       m.contact_no = contact;
                       m.uid = uiid;
                       m.Zone = zone;
                       m.Conection = contaction;
                       data.Add(m);

                   }

please help me out
thanks in advance
Posted
Updated 23-Aug-12 7:40am
v2
Comments
[no name] 23-Aug-12 14:09pm    
"i dont understand what i need to do"... and that means what exactly? What do you not understand?

1 solution

The code seems to be wrong (sql portion).

As you said, you need the user data as well as arear data, I don't see any data you considered from arear,

So, you need to change your sql like
SELECT * FROM userdata U, arear A where U.uid=A.uid


Second thing, you can make your code more robust, is to write the sql to get day/month.
So, you don't need to add a logic in the loop.
This part I leave it to you.

Hope this helps.

cheers
 
Share this answer
 

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