0

I have an access database table with 3 columns (ID,Person,Formation_Date). The difficulties I face are to retrieve from the table the person where the difference between the Formation_Date and the Date of Today is greater than 90 (Formation_Date-Today >90). And paste them in a DataGridView.

I don't know how to make such query

enter image description here

this is what i have done for now!

con.Open();
        OleDbCommand cmd = new OleDbCommand();
        cmd.Connection = con;
        string query = " select * from StatBD ";
        cmd.CommandText = query;
        DataTable dt = new DataTable();
        OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
        adapter.Fill(dt);
        dataGridView1.DataSource = dt;
        con.Close();
fedorqui
  • 275,237
  • 103
  • 548
  • 598
  • 1
    All those duplicates show you how to create an OleDb query against an Access DB using parameters, that is what you want to do. Use the current c# Date and subtract 90 days from that and use that as your parameter in your query. If you do not know how to write a where clause for Access then you need to take a step back and figure that out first (in which case I recommend using MS Access query editor to get your query correct first before encoding it in your app). – Igor Sep 19 '17 at 10:52
  • ok thank igor. Let me try that – Rahim Pamelo Marakash Ndane Sep 19 '17 at 11:47
  • Please i don't understand when you say marked as duplicate. what does it means ? – Rahim Pamelo Marakash Ndane Sep 19 '17 at 11:50
  • It means similar questions have been asked in the past with answers/solutions that are similar to the solution you need. Read the duplicates on how to use parameters and follow my advice in my previous comment. – Igor Sep 19 '17 at 11:52
  • please igor sorry but i can find any question similar to what am looking for please can you give me a link to any of the previous post. Thanks in avance – Rahim Pamelo Marakash Ndane Sep 19 '17 at 12:09

0 Answers0