This is my table in db
create table gridview(id bigint identity(1,1),name varchar(65),startdate varchar(1000),enddate varchar(1000),gender char(25),mobileno bigint,designition varchar(100),
country nvarchar(65),state nvarchar(65),city nvarchar(65))
i want to write a procedure for from date to to to date
once i click on button it should display only records between the two dates only pls help me
This is my procedure
create PROCEDURE sp_SearchCustomerDetailsByDate
@StartDate varchar(100),
@EndDate varchar(100)
AS
BEGIN
select * from gridview where startdate between @StartDate and @EndDate
END
This is My code for getting date
private DataTable GetDate(string fromdate, string enddate)
{
using (SqlCommand cmd = new SqlCommand("sp_SearchCustomerDetailsByDate", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@StartDate",fromdate);
cmd.Parameters.AddWithValue("@EndDate",enddate);
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
}
}
This is my button1click code
protected void Button1_Click(object sender, EventArgs e)
{
DataTable dt = GetDate(TextBox12.Text,TextBox13.Text);
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
pls help me out