I want to check a selected date out of txtFrom and compare if that specific date exists. It should give me an alert, but it doesn't check. As a beginner I don't know if I wrote the code well, please can somebody help me? These are my codes:
string conn = WebConfigurationManager.ConnectionStrings["DIVIHOTELConnectionString"].ConnectionString;
SqlConnection myconn = new SqlConnection(conn);
SqlCommand cmd = new SqlCommand("select * from MyBooking where FromDate='" + txtFrom.Text + "'", myconn);
myconn.Open();
SqlDataReader dr = cmd.ExecuteReader();
dr.Read();
if (txtFrom.Text == dr.GetString(1))
{
ScriptManager.RegisterStartupScript(this, GetType(), "showalert","alert('This particular date has been booked already, please select new date !');", true);
}