I am using MS Access as my database and c# as front end. I want to fetch data from a specific date of any month and year. I got the result only for two digit dates(10,11,12.....) but not for single digit(01,02,03,.......,09)
Here is the code
string d = dateTimePicker1.Value.Date.ToString("dd");
string constr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Auto_Finance.accdb;Persist Security Info=False;";
OleDbConnection con = new OleDbConnection(constr);
con.Open();
//string sql1 = @"select * from Party_Det order by PName asc where Loandate like '%'" + d + "'%' order by PName asc ";
//string sql1 = @"select * from Party_Det order by PName asc where Loandate like '*',@Loandate";// order by PName asc ";
//string sql1 = @"select * from Party_Det where Loandate like '*',@Loandate";// order by PName asc ";
string sql1 = @"select * from Party_Det where Day(Loandate)=@Loandate order by PName asc ";
OleDbCommand cmd1 = new OleDbCommand(sql1, con);
cmd1.Parameters.AddWithValue("@Loandate", d);
OleDbDataAdapter da = new OleDbDataAdapter(cmd1);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();
Thank You