sandy123
January 19th, 2006, 02:49 PM
Hello! and Help if possible!!!
I am creating a booking system in ASP and C#. I have an SQL database that stores the calendar info on some employees, including start and end dates of their current meetings.
I am stuck! i am a newbie at this! ive got a pop up calendar that populates a text box with the start date selected and the same for the end date. What i need to do is pass this value to the start date field column in my sql database and iterate through the rows to see if that date already exists for that employee! So far, i have this....
protected void Button3_Click(object sender, EventArgs e)
{
String name = ListBox1.Text.ToString();
String proposedStart = txtStartDate.Text.ToString();
String proposedEnd = txtEndDate.Text.ToString();
SqlConnection sqlConnect = new SqlConnection(ConfigurationManager.ConnectionStrings["MeetingConnectionString"].ToString());
SqlCommand sqlComm = new SqlCommand("SELECT 1 FROM Calendar WHERE WhoToInvite = '" + name + "' AND NOT ('"+ proposedEnd +"' <= StartDate OR '"+ proposedStart +"' >= EndDate )", sqlConnect);
sqlConnect.Open();
IDataReader Reader = sqlComm.ExecuteReader();
if (Reader.Read())
Response.Write("NO overlaps");
else
Response.Write("Overlaps");
sqlConnect.Close();
}
But it seems to work on some occassions and not on others... as in, the overlap is correctly identified, sometimes, but not at other times. ahhhh!
if anyone has any ideas in how to do this, any help would be extremely gratefully appreciated!!!!!
Thanks,
Sandy
I am creating a booking system in ASP and C#. I have an SQL database that stores the calendar info on some employees, including start and end dates of their current meetings.
I am stuck! i am a newbie at this! ive got a pop up calendar that populates a text box with the start date selected and the same for the end date. What i need to do is pass this value to the start date field column in my sql database and iterate through the rows to see if that date already exists for that employee! So far, i have this....
protected void Button3_Click(object sender, EventArgs e)
{
String name = ListBox1.Text.ToString();
String proposedStart = txtStartDate.Text.ToString();
String proposedEnd = txtEndDate.Text.ToString();
SqlConnection sqlConnect = new SqlConnection(ConfigurationManager.ConnectionStrings["MeetingConnectionString"].ToString());
SqlCommand sqlComm = new SqlCommand("SELECT 1 FROM Calendar WHERE WhoToInvite = '" + name + "' AND NOT ('"+ proposedEnd +"' <= StartDate OR '"+ proposedStart +"' >= EndDate )", sqlConnect);
sqlConnect.Open();
IDataReader Reader = sqlComm.ExecuteReader();
if (Reader.Read())
Response.Write("NO overlaps");
else
Response.Write("Overlaps");
sqlConnect.Close();
}
But it seems to work on some occassions and not on others... as in, the overlap is correctly identified, sometimes, but not at other times. ahhhh!
if anyone has any ideas in how to do this, any help would be extremely gratefully appreciated!!!!!
Thanks,
Sandy