I need to call my datetime variable from another class,
this is the code for querying with date condition
static DataTable GetCustomerRecords(DateTime date, DateTime date2)
{
var connSettings = ConfigurationManager.ConnectionStrings["MyDB"];
{
string CN = connSettings.ConnectionString;
MySqlConnection conn = new MySqlConnection(CN);
MySqlCommand cmd = new MySqlCommand("select value1, value2, value3, date2 from dummy table where date1 >= CAST(@startDate AS DATE) and date2 <= CAST(@endDate AS DATE)", conn);
cmd.Parameters.AddWithValue("@startDate", date);
cmd.Parameters.AddWithValue("@endDate", date2);
MySqlDataAdapter data = new MySqlDataAdapter(cmd);
conn.Open();
DataTable dt = new DataTable();
data.Fill(dt);
return dt;
}
}
public object QueryRecords(DateTime date, DateTime date2)
{
DataTable table = GetCustomerRecords();
return table;
}
My DatePicker 1 and 2 ValueChanged
GetRecords Retrieve = new GetRecords();
private void datePicker1_ValueChanged(object sender, EventArgs e)
{
Retrieve.GetCustomerRecords(date)/error here of course
}
private void datePicker2_ValueChanged(object sender, EventArgs e)
{
Retrieve.GetCustomerRecords(date2)/error here of course
}
i don't know how to do proper calling of method, im new at this.