Good Morning all, i have a problem when display data from my mdb database.
My Code :
private void btn_Preview_Click(object sender, EventArgs e)
{
//MessageBox.Show(dateTimePicker1.Value.ToShortDateString());
dataGridView1.Refresh();
string sql = "SELECT * FROM DATA where tgl BETWEEN #01/01/2017# AND #30/01/2017# order by tgl Asc";
//string sql = "SELECT * FROM DATA where tgl = #07/01/2017#";
OleDbConnection conn = new OleDbConnection(koneksi);
conn.Open();
OleDbDataAdapter da = new OleDbDataAdapter(sql, conn);
DataSet ds = new DataSet();
da.Fill(ds, "DATA");
conn.Close();
dataGridView1.DataSource = ds.Tables["DATA"].DefaultView;
}
when i run the program
string sql = "SELECT * FROM DATA where tgl BETWEEN #01/01/2017# AND #30/01/2017# order by tgl Asc";
this is the result: Result when use show Between date
then i try to run with specific date :
string sql = "SELECT * FROM DATA where tgl = #07/01/2017#";
no record appear.
when i change #07/01/2017# to #29/12/2016# the data is loaded to Datagridview1
Please tell me what wrong with my code. when i use #07/01/2017# the data can't loaded to datagridview, but when i use date between 01/01/2017 and 30/01/2017 the data is loaded and contain 07/01/2017.
Thanks
Check the date format, it is the most probable cause of this irregularity. Try 01/07/2017 instead. You can also change the date format in control panel -> clock language, and region, so you can have the date/time format of your choice.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.