Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static DataSet getOrdersDataSet(string dateStart, string dateEnd)
- {
- SqlConnection conn = Utils.getSQLConnection();
- SqlCommand cmd = new SqlCommand();
- cmd.CommandText = "SELECT orders.oid, orders.orddate, itemsPerOrder.itemsCount FROM orders, (";
- cmd.CommandText += "SELECT oid, count(*) itemsCount FROM items GROUP BY oid";
- cmd.CommandText += ") itemsPerOrder WHERE orders.oid = itemsPerOrder.oid";
- if (dateStart != null && dateStart.Length > 0)
- cmd.CommandText += " AND DATEDIFF(day,'"+dateStart+"',orddate) >= 0";
- if (dateEnd != null && dateEnd.Length > 0)
- cmd.CommandText += " AND DATEDIFF(day,'"+dateEnd+"',orddate) <= 0";
- cmd.Connection = conn;
- SqlDataAdapter sda = new SqlDataAdapter();
- DataSet ds = new DataSet();
- sda.SelectCommand = cmd;
- conn.Open();
- sda.Fill(ds);
- conn.Close();
- return ds;
- }
Add Comment
Please, Sign In to add comment