hiii..
i want to get multiple rows from database...
SqlCommand cmd = new SqlCommand("SELECT * FROM dateshort WHERE from_date BETWEEN '" + from + "' AND '" + to + "' ", mycon);
using this query i want to fetch the in between dates ...
but i don't konw how to implement in c#...

Ranjit PowarRank #553 · 4.4K reputationPosted Nov 22, 2014, 8:33 PM EST
SqlDataAdapter da=new SqlDataAdapter("SELECT * FROM dateshort WHERE from_date BETWEEN '" + from + "' AND '" + to + "' ", mycon);
DataTable dt=new DataTable();
da.Fill(dt);
Now you can get all selected rows in data table.
Vikram AgrawalRank #4,713 · 329 reputationPosted Nov 22, 2014, 8:45 PM EST
If at all you want to to retrieve data from database into your application you can do it as following:
SqlConnection con=new SqlConnection("CONNECTIONSTRING");
SqlCommand cmd=new SqlCommand("Select * From myTable Where DateColumn Between '" + fromDate + "' AND '" + toDate + "'",con);
con.Open();
SqlDataReader reader=cmd.ExecuteReader();
Now u will get all filtered record in reader object and you can use this as per your need.
Thanks.
Please Mark This answer if it is helpful to you.
Ahmed JS80 reputationPosted Nov 23, 2014, 5:21 AM EST
use this code
DateTime from =Convert.ToDateTime(from);
DateTime to =Convert.ToDateTime(to);
SqlCommand cmd = new SqlCommand("SELECT * FROM dateshort WHERE from_date BETWEEN '" + from.ToString("dd/MMM/yyyy") + "' AND '" + to.ToString("dd/MMM/yyyy") + "' ", mycon);
Please Mark This answer if it is helpful to you.