I am trying to do a project which uses Visifire to display graphed data. It takes in a single DataTable. I need to create an SQL query that searches a date column for a particular month (format is: Friday, 03 November 2017) and then stores how many times that month is repeated. It has to do this for all 12 months. This is done in C# in visual studio. Currently, it displays no data on the line graph.
public DataTable ReadDataMonthlyBooked()
{
// Declare references (for table, reader and command)
DataTable monthlyBookedTable = new DataTable();
SqlDataReader reader;
SqlCommand command;
string selectString = "SELECT COUNT (BookingNum) AS Bookings "
+ "FROM Booking "
+ "WHERE Booking.EndDate LIKE 'January' "
+ "AND Booking.EndDate LIKE 'February' "
+ "AND Booking.EndDate LIKE 'March' "
+ "AND Booking.EndDate LIKE 'April' "
+ "AND Booking.EndDate LIKE 'May' "
+ "AND Booking.EndDate LIKE 'June' "
+ "AND Booking.EndDate LIKE 'July' "
+ "AND Booking.EndDate LIKE 'August' "
+ "AND Booking.EndDate LIKE 'September' "
+ "AND Booking.EndDate LIKE 'October' "
+ "AND Booking.EndDate LIKE 'November' "
+ "AND Booking.EndDate LIKE 'December'";
try
{
// Create a new command
command = new SqlCommand(selectString, cnMain);
// open the connection
cnMain.Open();
command.CommandType = CommandType.Text;
reader = command.ExecuteReader();
// read data from readerObject and load in table
monthlyBookedTable.Load(reader);
reader.Close(); //close the reader
cnMain.Close(); //close the connection
return monthlyBookedTable;
}
catch (Exception ex)
{
return (null);
}
}
This is the current SQL query I have and I hope its hopelessly wrong with logic errors but I do not know SQL well enough.