Click here to Skip to main content
Rate this: bad
good
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 at 17-Dec-12 21:45pm
   
yarakiran at 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 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 at 17-Dec-12 21:56pm
   
Thanks, but I want the query only..
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

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,745
1 OriginalGriff 6,696
2 CPallini 5,315
3 George Jonsson 3,599
4 Gihan Liyanage 2,650


Advertise | Privacy | Mobile
Web01 | 2.8.140922.1 | Last Updated 18 Dec 2012
Copyright © CodeProject, 1999-2014
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