Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

How to get records from access database where DOB matches with today's Date..

Thank You..
Posted
Comments
[no name] 17-Dec-12 21:45pm    
yarakiran 17-Dec-12 21:49pm    
I tried With Date(); but its checking Year also.. But I want only BirthDay Date Matches with Today...

hope this would do.

string query = "select id,name from Book where MONTH(DOB)= "+DateTime.Now.Month +" and Day(DOB)=" +DateTime.Now.Day ;
 
Share this answer
 
v2
This's an example of selecting from Access database,you have edit the query and the path of your DB... good lock

C#
using System.Data.SqlClient;
using System.Data.OleDb;


OleDbConnection conn = new OleDbConnection();
String connectionString = @"Provider=Microsoft.JET.OlEDB.4.0;"
+ @"Data Source=E:\DB.mdb";
conn = new OleDbConnection(connectionString);
conn.Open();

string query = "select id,name from Book;";

OleDbCommand command = new OleDbCommand(query, conn);
OleDbDataReader reader = command.ExecuteReader();
try
{
while (reader.Read())
Console.WriteLine(String.Format("{0} {1}", reader[0], reader[1]));

}
finally
{
reader.Close();
conn.Close();
}
 
Share this answer
 
v4
Comments
yarakiran 17-Dec-12 21:56pm    
Thanks, but I want the query only..

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