Click here to Skip to main content
12,302,084 members (57,836 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# Access
Hi,

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

Thank You..
Posted 17-Dec-12 15:39pm
Comments
Krunal Rohit 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...
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

hope this would do.

string query = "select id,name from Book where MONTH(DOB)= "+DateTime.Now.Month +" and Day(DOB)=" +DateTime.Now.Day ;
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

This's an example of selecting from Access database,you have edit the query and the path of your DB... good lock

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();
}
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160530.1 | Last Updated 18 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100