i have problem to count total record here is my code for count total record
DateTime Todaydate = DateTime.Now;
DateTime Pridaydate = DateTime.Now.AddDays(-5);
int TotalPendingOrder = 0;
SqlConnection con = new SqlConnection(ConnString);
string Qry = "select COUNT(*) from OrderMaster where OrderDate between CONVERT(CHAR(10),'" + Pridaydate + "',112) and CONVERT(CHAR(10),'" + Todaydate + "',112) and OrderStatus='Confirm'";
SqlDataAdapter da = new SqlDataAdapter(Qry, con);
DataTable dt = new DataTable();
if (dt.Rows.Count > 0)
Summary.Visible = true;
TotalPendingOrder = dt.Rows.Count;
lblpending.Text = "There are " + " " + TotalPendingOrder.ToString() + " Orders Pending From Last 5 Days Please Shipped that order." + "<br/>" + " To Ship that order Please";
it count only 1 record
when i run this code in sql it count 25 record here is sql query.
select COUNT(*) from OrderMaster where OrderDate between CONVERT(CHAR(10),(GETDATE()-5),112) and CONVERT(CHAR(10),GETDATE(),112) and OrderStatus='Confirm'
where i m wrong in coding to get records..
Thank You all..!!!
You have to remove the "COUNT(*)" and just use "*" for the query in the sql data adapter
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)