Click here to Skip to main content
11,581,186 members (57,726 online)
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 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 at 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
0 OriginalGriff 260
1 Sergey Alexandrovich Kryukov 155
2 virusstorm 114
3 Frankie-C 105
4 RyanDev 84
0 OriginalGriff 1,183
1 Sergey Alexandrovich Kryukov 825
2 Abhinav S 597
3 F-ES Sitecore 500
4 Suvendu Shekhar Giri 433


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 18 Dec 2012
Copyright © CodeProject, 1999-2015
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