Filter Data According to Month and Year in Asp.Net

In this post Filter Data According to Month and Year

Important Namespaces Used

using System.Data;
using System.Data.SqlClient;


Filter Button Click Event Coding

String mycon = "Data Source=HP-PC\\SQLEXPRESS; Initial Catalog=BankingRecord; Integrated Security=True";
        String myquery = "select transactionid, convert(varchar, cast(convert(varchar(10), transactiondate, 110) as datetime), 106) as transactiondate, transdetail, transamount from transactiondetail where month(transactiondate)=" + DropDownList1.SelectedItem.Value+" and year(transactiondate)="+TextBox1.Text;
        SqlConnection con = new SqlConnection(mycon);
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = myquery;
        cmd.Connection = con;
        SqlDataAdapter da = new SqlDataAdapter();
        da.SelectCommand = cmd;
        DataSet ds = new DataSet();
        GridView1.DataSource = ds;

0 Comment's

Comment Form