1
Answer

datetimepicker

Shyja Abraham

Shyja Abraham

13y
3.7k
1

 i have a form with datetimepicker,button,datagridview. in SQL i have a table with feeid,feeno,classid,feedate,total named fee.

when we click the button,  I want to select all the data from sql  according to Selected date
 (datetimepicker) and it will displayed in datagridview.
i use this code. but this is not working.


private void button1_Click(object sender, EventArgs e)
{ cmd.CommandText = "select * from fee where feedate='" + DateTime.Parse(dateTimePicker1.Value.ToString()) + "'"; da.SelectCommand = cmd;
da.Fill(ds, "name");
DataTable dt1 = ds.Tables["name"];
//dt.Clear();
displaygrid.DataSource = dt1;
Answers (1)